我正在一個項目上工作。我想知道「我的文本框是否滑出幻燈片?」 。如果是,則顯示錯誤消息。如何使用vba獲取電源點幻燈片尺寸?
所以我的邏輯是,如果我找到了幻燈片的尺寸,然後我將用它在IF ... else條件,如:
If textbox_position < slide_dimension then
#Error
end if
如果您有任何其他的想法,那麼請告訴我。
謝謝
我正在一個項目上工作。我想知道「我的文本框是否滑出幻燈片?」 。如果是,則顯示錯誤消息。如何使用vba獲取電源點幻燈片尺寸?
所以我的邏輯是,如果我找到了幻燈片的尺寸,然後我將用它在IF ... else條件,如:
If textbox_position < slide_dimension then
#Error
end if
如果您有任何其他的想法,那麼請告訴我。
謝謝
演示文稿的.PageSetup.SlideWidth和.SlideHeight屬性將爲您提供滑動點的維度。
你的功能將需要像做(關閉頭上,從空氣中..):
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
爲什麼你不使用PowerPoint的佔位符來做到這一點?例如:
Sub SetText(IndexOfSlide As Integer, txt As String)
'http://officevb.com
ActivePresentation.Slides(IndexOfSlide).Shapes.Placeholders(1).TextFrame.TextRange.Text = txt
End Sub
你可以調用這個子和傳遞參數
IndexOfSlide與一些幻燈片,TXT與文本創建。
非常感謝布魯諾。讓我嘗試。 –
好代碼史蒂夫! –
嘿,謝謝你的朋友。你太好了 –