我正在开发一个项目。我想要找出“我的文本框是否超出了幻灯片的范围,如果是,则显示错误消息。”
因此,我的逻辑是,如果我找到幻灯片的尺寸,那么我将在IF...Else条件语句中使用它:
If textbox_position < slide_dimension then
#Error
end if
如果你有其他想法,请告诉我。
谢谢。
我正在开发一个项目。我想要找出“我的文本框是否超出了幻灯片的范围,如果是,则显示错误消息。”
因此,我的逻辑是,如果我找到幻灯片的尺寸,那么我将在IF...Else条件语句中使用它:
If textbox_position < slide_dimension then
#Error
end if
如果你有其他想法,请告诉我。
谢谢。
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