mhartman1
Technical User
- May 5, 2006
- 155
Hello, I am trying to delete all background pages in Visio 2003 using the following code:
Sub DeleteBackGroundPages()
Dim MyPage As Page
For Each MyPage In ActiveDocument.Pages
'Test for a "Background" page here
If MyPage.Background = True Then
'Delete the page
MyPage.Delete True
End If
Next MyPage
End Sub
However when the code runs it only deletes a few pages at a time. For testing purposes, I used a document with ONE foreground page and FOUR background pages. On the first run of the procedure, TWO background pages were deleted, then next run deleted another page and finally on the third run, the fourth background page was deleted. I have tried it using "False" for the page reordering as well with no success.
Any advice would be greatly appreciated.
Thanks in advance.
Mark
Sub DeleteBackGroundPages()
Dim MyPage As Page
For Each MyPage In ActiveDocument.Pages
'Test for a "Background" page here
If MyPage.Background = True Then
'Delete the page
MyPage.Delete True
End If
Next MyPage
End Sub
However when the code runs it only deletes a few pages at a time. For testing purposes, I used a document with ONE foreground page and FOUR background pages. On the first run of the procedure, TWO background pages were deleted, then next run deleted another page and finally on the third run, the fourth background page was deleted. I have tried it using "False" for the page reordering as well with no success.
Any advice would be greatly appreciated.
Thanks in advance.
Mark