visOpenHidden & Setting Page Index in Visio 2010

Started by Dan_H, October 22, 2012, 11:53:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dan_H

I develop a lot of Visio automation utilities for my organisation, and we are in the process of upgrading to Visio 2010. A compatibility issue has been reported to me and I am completely stumped; one of my tools will move certain pages of a document it is processing to the end, and I do this simply by setting the page index.

The following code simulates the problem (not the actual code but replicates the issue):
Set visdoc = Documents.OpenEx("SomePath\Test.vsd", visOpenHidden + visOpenCopy)
   
For Each vPage In visdoc.Pages
    If Not vPage.Background Then vPage.Index = 1
Next vPage
   
visdoc.Close


This will successfully change the page ordering in 2003, but in 2010 I get a "Requested operation is presently disabled" error.

If I remove the visOpenHidden flag, it works perfectly, but obviously displays the doc being processed, which is not an acceptable solution to me. Seemingly setting the doc to hidden is somehow disabling the page re-ordering capability.

Has anyone else come across this? I can find no other references on the internet, which is unusual in itself, and I have seen the issue on several machines (all running Windows 7), so seems to be consistent as a Visio 2010 problem and not machine related.

Paul Herber

I wonder if this might be an issue with looping through the pages using the For Each method.
Could you try using a normal page loop.
Electronic and Electrical engineering, business and software stencils for Visio -

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

Dan_H

#2
That was the first thing I tried - I wondered if some of the rules for changing elements within the collection had been tightened in 2010, but sadly I get the same result :(

I've just double checked:
Dim visdoc As Visio.Document
Dim n As Integer

Set visdoc = Documents.OpenEx("SomePath\Test.vsd", visOpenHidden + visOpenCopy)

For n = 1 To visdoc.Pages.Count
    If Not visdoc.Pages(n).Background Then visdoc.Pages(n).Index = 1
Next n

visdoc.Close
Set visdoc = Nothing


Same Error

The fact it works when you remove the visOpenHidden flag is the real crux of this I think - I am beginning to wonder if this is a bug in vis 2010