How to get power point slide size using vba?

I am working on one project. In which I want to know: β€œIs my text box disconnected from the slide or not?” If yes, then show an error message.

so my logic is that I found the size of the slide, then I will use it in IF ... Else condition like:

If textbox_position < slide_dimension then #Error end if 

If you have any other idea then tell me.

thanks

+8
vba powerpoint-vba powerpoint
source share
2 answers

Presentation properties .PageSetup.SlideWidth and .SlideHeight will give you slide sizes in points.

Your function will have to do something like (outside the head and out of thin 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 
+16
source share

Why don't you use PowerPoint placeholders for this? eg:

 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 parameter sub and pass

IndexOfSlide with a series of slides and a txt with text to create.

+1
source share

All Articles