If Page Exists

Started by hill041, July 22, 2020, 08:17:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hill041

Hi all,

Hope you are all well!

I'm trying to alter some shape data on a number of pages but do not want to include any pages that the user of my template may have already deleted.

An expression such as the following would be ideal but obviously does not exist! Anyone know of another way around this?

If Application.ActiveDocument.Pages.PageExists("IF Table Cont") then

...
...
...

end if

Thanks In Advance!

Dan.

Paul Herber

You could try accessing the page name in the usual manner and if it doesn't exist you will get an exception, so the exception handler then handles the non-exist path.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

JohnGoldsmith

You can either loop through the Pages collection with a for or foreach:


https://visualsignals.typepad.co.uk/vislog/2007/11/looping-through.html


or Pages has GetNames and GetNamesU methods:


https://docs.microsoft.com/en-gb/office/vba/api/visio.pages.getnamesu


Best regards


John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/