我正在研究一个项目。其中我想找出“我的文本框是否已经滑出幻灯片?” 。如果是,则显示错误信息。
所以我的逻辑是,如果我找到幻灯片的尺寸,那么我将在IF中使用它...其他条件如:
If textbox_position < slide_dimension then
#Error
end if
如果您有任何其他想法,请告诉我。
谢谢
答案 0 :(得分:17)
演示文稿的.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
答案 1 :(得分:1)
为什么不使用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。