Visio Guy

Visio Discussions => Programming & Code => Topic started by: Hamwic on November 10, 2015, 02:09:36 PM

Title: Excluding Page from a "For Each Page" loop
Post by: Hamwic on November 10, 2015, 02:09:36 PM
I am needing to loop through each page sequentially, using a "For Each Page" loop, but need to exclude one (as it is irrelevant". Is there any way of doing this?

Thanks (as always) in advance!
Title: Re: Excluding Page from a "For Each Page" loop
Post by: Nikolay on November 10, 2015, 02:21:06 PM
I think this is pretty much straightforward... What have you tried so far (is there some issue)?
Title: Re: Excluding Page from a "For Each Page" loop
Post by: Paul Herber on November 10, 2015, 02:28:04 PM
If vsoPage.Name = "xxx" then
...
else
...


{Ed} modified to suit your code posted just now
Title: Re: Excluding Page from a "For Each Page" loop
Post by: Hamwic on November 10, 2015, 02:30:18 PM
I'm sure it is pretty straight forward... The issue is that I don't know how to exclude a Page, as the loop will call each Page sequentially. They are not called directly by their name.

    For Each vsoPage In ThisDocument.Pages
        Application.ActiveWindow.Page = vsoPage

        For Each vsoShape In vsoPage.Shapes
            vsoUserName = vsoShape.CellsU("prop." & strFieldtoUpdate).ResultStr(visNone)
           
            intPropRow2 = vsoShape.AddRow(visSectionProp, visRowLast, visTagDefault)
            vsoShape.CellsSRC(visSectionProp, intPropRow2, visCustPropsValue).FormulaU = """" & vsoSuperUPN & """"
            Application.EndUndoScope UndoScopeID1, True
                   
        Next
    Next


I'm new to Visio and very rusty with VBA. This is a huge learning curve (again)!!
Title: Re: Excluding Page from a "For Each Page" loop
Post by: Hamwic on November 10, 2015, 02:47:59 PM
Thanks Paul (again!).

Pretty obvious really... Just one of those situations where the trees are obscuring the wood!
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 53 (show)
Files included: 25 - 925KB. (show)
Memory used: 772KB.
Tokens: post-login.
Cache hits: 7: 0.00094s for 22,301 bytes (show)
Cache misses: 1: (show)
Queries used: 9.

[Show Queries]