VBA Powerpoint: delete all guides

Luis Diaz
Luis Diaz used Ask the Experts™
on
Hello experts,

I have the following procedure in order to reset & delete the various guides.
Sub DeleteGuides()
    With ActivePresentation.Guides
        ' Delete the second guide
        .Item(2).Delete
    End With
End Sub

Open in new window

However when I launch it, I am not able to reset all of guides

Could you please  help me to adjust?

Thank you in advance for your help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Consulting
Distinguished Expert 2017
Commented:
Hi, you need to reverse browse the Guides collection, the code you posted only remove one guide.
Sub DeleteGuides
    With ActivePresentation.Guides
        Dim i As Integer
        For i = .Count to 1 Step -1
            .Item(i).Delete
        Next
    End With
End Sub

Open in new window

Luis DiazIT consultant

Author

Commented:
Tested and it works. Thank you very much for your help.

Regards,

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial