Link to home
Start Free TrialLog in
Avatar of brothertruffle880
brothertruffle880Flag for United States of America

asked on

Visio VBA - How to delete sheets 12 to the end

I would like to delete sheets 12 to the very last sheet in my collection of visio diagrams.
Can someone help me with the code on this?
I would like to keep sheets (i.e. diagrams)  1 through 11.
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Assuming the number og pages can vary but that you always want to delete the last 12 pages then for example:

Sub del12()
Dim doc As Document
Dim sh As Page

    Set doc = ActiveDocument
    If doc.Pages.Count <= 12 Then Exit Sub
    For x = 1 To 12
        doc.Pages(doc.Pages.Count).Delete False
    Next
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Scott Helmers
Scott Helmers
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yeah, I focussed on last 12 pages to delete NOT to keep only the first 11, doh!

Chris