Re: Center object position with VBA

  • Thread starter Thread starter Steve Rindsberg
  • Start date Start date
S

Steve Rindsberg

Anyone knows how to center an object on the slideshow window with VBA code? I
don't want to put it to a specific location using Left position, but center
it in the page automatically as it will vary in lenght?

What kind of object? If it's a shape:

' this will center it when clicked
' if you don't need that, just get a reference to oSh some other way

Sub CenterMe(oSh As Shape)
With oSh
.Left = (ActivePresentation.PageSetup.SlideWidth - .Width) / 2
.Top = (ActivePresentation.PageSetup.SlideHeight - .Height) / 2
End With
End Sub

If it's a command button or the like, something like this:

Private Sub CommandButton1_Click()
With Me.CommandButton1
.Left = (ActivePresentation.PageSetup.SlideWidth - .Width) / 2
.Top = (ActivePresentation.PageSetup.SlideHeight - .Height) / 2
End With
SlideShowWindows(1).View.GotoSlide (Me.SlideIndex)
End Sub
 
Back
Top