簡體   English   中英

如何使用vba獲得power point slide尺寸?

[英]How to get power point slide dimension using vba?

我正在做一個項目。 其中我想找出“我的文本框是否已經滑出幻燈片?” 如果是,則顯示錯誤消息。

所以我的邏輯是,如果我找到了幻燈片的尺寸,那么我將在IF中使用它...其他條件如:

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帶有一些slide和txt,帶有要創建的文本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM