2012-01-25 5 views
8

मैं एक परियोजना पर काम कर रहा हूं। जिसमें मैं जानना चाहता हूं "क्या मेरा टेक्स्टबॉक्स स्लाइड से बाहर है या नहीं?" । यदि हां तो त्रुटि संदेश दिखाएं।वीबीए का उपयोग कर पावर प्वाइंट स्लाइड आयाम कैसे प्राप्त करें?

तो मेरे तर्क अगर मैंने पाया स्लाइड के आयाम तो मैं अगर में यह प्रयोग करेंगे ... वरना हालत की तरह:

If textbox_position < slide_dimension then 
#Error 
end if 

आप किसी भी अन्य विचार है तो कृपया मुझे बताओ।

धन्यवाद

उत्तर

16

प्रेजेंटेशन का .PageSetup.SlideWidth और .SideHeight गुण आपको बिंदुओं में स्लाइड के आयाम देंगे। एक बहुत ब्रूनो

Function IsOffSlide (oSh as Shape) as Boolean 
    Dim sngHeight as single 
    Dim sngWidth as Single 
    Dim bTemp as Boolean 

    bTemp = False ' by default 

    With ActivePresentation.PageSetup 
    sngHeight = .SlideHeight 
    sngWidth = .SlideWidth 
    End With 

    ' this could be done more elegantly and in fewer lines 
    ' of code, but in the interest of making it clearer 
    ' I'm doing it as a series of tests. 
    ' If any of them are true, the function will return true 
    With oSh 
    If .Left < 0 Then 
     bTemp = True 
    End If 
    If .Top < 0 Then 
     bTEmp = True 
    End If 
    If .Left + .Width > sngWidth Then 
     bTemp = True 
    End If 
    If .Top + .Height > sngHeight Then 
     bTemp = True 
    End If 
    End With 

    IsOffSlide = bTemp 
End Function 
+0

अच्छा कोड स्टीव! –

+0

अरे धन्यवाद दोस्त। आप बहुत अच्छे हैं –

+0

धन्यवाद, दोस्तों। –

1

आप इस बनाने के लिए पावर प्वाइंट की एक प्लेसहोल्डर का उपयोग नहीं क्यों? उदाहरण के लिए:

Sub SetText(IndexOfSlide As Integer, txt As String) 
'http://officevb.com 
     ActivePresentation.Slides(IndexOfSlide).Shapes.Placeholders(1).TextFrame.TextRange.Text = txt 
End Sub 

आप इस उप कॉल और बनाने के लिए एक पाठ के साथ स्लाइड और txt की संख्या के साथ मानकों

IndexOfSlide पारित कर सकते हैं।

+0

धन्यवाद:

आपका समारोह की तरह कुछ करने के लिए की आवश्यकता होगी (सिर के ऊपर से और हवा से बाहर ..)। मुझे कोशिश करने दो। –

संबंधित मुद्दे