我正在一个项目上工作。我想知道“我的文本框是否滑出幻灯片?” 。如果是,则显示错误消息。如何使用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与文本创建。
非常感谢布鲁诺。让我尝试。 –
好代码史蒂夫! –
嘿,谢谢你的朋友。你太好了 –