pg.index = n doesn't move page

Started by scott, September 16, 2014, 10:09:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

scott

I've used code like this to relocate a page within a document many times:
dim pg as Visio.Page
set pg = ...
pg.index = n


where n is the desired new page position within the document. Normally works fine...

However, I have a document in which nothing happens when I issue pg.index = n. The event monitor looks normal
6154 > EnterScope  [1795;0;Reorder Pages;467164]
6155 | DocumentChanged TEST doc for Training and Resp Pages.vsd /pagesreordered  [/doc=1]
6156 < ExitScope  [1795;0;Reorder Pages;467164]


but the page doesn't move. I can move the page manually via the UI.

Is there a doc property or something else that could be preventing page reordering from working?

Thanks

JohnGoldsmith

Hello Scott,

Page indices are 1 based so is it possible you're trying to use a zero index?

Otherwise, do you have a test document that shows the problem in more detail?

Best regards

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

aledlund

This from John Marshall's site

Page Order: This code will change the order of a page.

To put the third page in front of the second page.

Activedocument.Pages.Item(3).Index = 2

al

scott

Thanks, John and Al. The index value in question is in the teens -- attempting to move the page from approximately 19 to 14, for example.

I can't reproduce the problem outside a specific document at the moment, but I can't post the problem document publicly. Assuming I haven't missed a "don't allow page moves" property somewhere, I'll continue to experiment...

scott

It turns out the problem has to do with the existence of a hidden page in the document. If I unhide the page, the page reorder operation works fine. Further experimentation required, but at least the problem is reproducible and there is a workaround.

Jumpy

Could you elaborate on the workarround for later users that encounter the same problem?

Do you move all hidden pages to the end?

scott

Sorry for the very long delay in responding...

In case anyone else has this problem, the workaround in VBA is fairly simple. To answer Jumpy's question: it does not require moving the hidden page(s) to the end. (In my case I couldn't have done that -- the reason for the existence of the hidden page is to act as a boundary between two sections of pages in the diagram.)

For VBA code to set a page index in order to move a page in a document that contains a hidden page, it is necessary to:

  • Unhide the hidden page(s)
  • set pg.index=n
  • rehide the hidden page(s)