Question

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 textbox_position < slide_dimension  then
#Error
end if

If you have any other idea then please tell me.

Thanks

Was it helpful?

Solution

The presentation's .PageSetup.SlideWidth and .SlideHeight properties will give you the dimensions of the slide in points.

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

OTHER TIPS

Why you not use a placeholders of PowerPoint to make this? 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top