简体   繁体   English

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

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

I am working on one project. 我正在做一个项目。 In which i want to find out " Is my textbox going out of slide or not?" 其中我想找出“我的文本框是否已经滑出幻灯片?” . If yes then show error msg. 如果是,则显示错误消息。

so my logic is if i found the dimension of the slide then i will use it in IF...Else condition like : 所以我的逻辑是,如果我找到了幻灯片的尺寸,那么我将在IF中使用它...其他条件如:

If textbox_position < slide_dimension  then
#Error
end if

If you have any other idea then please tell me. 如果您有任何其他想法,请告诉我。

Thanks 谢谢

The presentation's .PageSetup.SlideWidth and .SlideHeight properties will give you the dimensions of the slide in points. 演示文稿的.PageSetup.SlideWidth和.SlideHeight属性将为您提供幻灯片的尺寸。

Your function would need to do something like (off top of head and out of the air ..): 你的功能需要做一些事情(头顶和空中......):

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

Why you not use a placeholders of PowerPoint to make this? 为什么你不使用PowerPoint的占位符来做到这一点? for example: 例如:

Sub SetText(IndexOfSlide As Integer, txt As String)
'http://officevb.com
       ActivePresentation.Slides(IndexOfSlide).Shapes.Placeholders(1).TextFrame.TextRange.Text = txt
End Sub

You can call this sub and pass parameters 您可以调用此子并传递参数

IndexOfSlide with a number of slide and txt with a text to create. IndexOfSlide带有一些slide和txt,带有要创建的文本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用vba附加excel工作簿以在power point中滑动 - How to attach a excel workbook to slide in power point using vba 如何使用VBA宏在Powerpoint幻灯片中“重置图片”? - How to “Reset Picture” in Power point Slide using VBA macro? 使用VBA获取Powerpoint幻灯片中同一对象两次单击之间的经过时间 - Get elapsed time between 2 clicks on the same object in power point slide using VBA 我想使用 vba 编辑现有幻灯片中的文本 - I want to edit a text in the existing power point slide using vba VBA:在单个 Power Point 幻灯片上定位 3 个图形 - VBA: Positioning 3 Graphs On A Single Power Point Slide 如何在MS Power Point演示文稿的一张主幻灯片中添加自定义文本占位符,并为每张幻灯片使用VBA脚本对其进行访问? - How to add a custom Text placeholder in one of the master slides in MS Power Point presentation and access it using VBA Script for each slide? 如果在电源点表中发现空单元格以及使用 vba 在哪张幻灯片中发现空单元格,则发出警报 - Alert if empty cell found in power point tables and in which slide using vba 删除Power Point幻灯片中的现有图表,并使用VBA替换为新图表 - Delete existing chart in Power Point slide and replace by new chart using VBA VBA-如何在Excel中选择特定图表并将其粘贴到Power Point的单个幻灯片中 - VBA - How to select specific charts in excel and paste them on single slide in power point Power Point VBA - 将图片从用户窗体复制到幻灯片 - Power Point VBA - Copy Picture from Userform to Slide
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM