I know how to read/set the visibility/printability/editability for a page layer.
I know how to read/set the normal "document-wide" visibility/printability/editability for a master layer.
However, the visibility/printability/editability of a master layer can, for any specific page, be set differently than the "document-wide" settings for that master layer through the "Current page, layers only" view of that page in the Object Manager.
Can that information be accessed through VBA?
I was able to do it, kinda a hack but it does work. I created a document with three pages, I added a MasterLayer named Master Layer 1. I hid the layer on Page 2.
Here is my code:
Sub MasterLayersIsVisible() Dim p As Page For Each p In ActiveDocument.Pages p.Activate p.Layers("MasterLayer 1").Activate Debug.Print p.Layers("MasterLayer 1").Name & " - " & p.Name & " Visible: " & ActiveLayer.Visible Next p End Sub
Here is the output:
MasterLayer 1 - Page 1 Visible: TrueMasterLayer 1 - Page 2 Visible: FalseMasterLayer 1 - Page 3 Visible: True
Hope that helps,
-Shelby
Thank you, Shelby.
I only recently became aware of the ability to have a "page-specific override" for a Master layer, e.g., making a Master layer non-printable only for a specified page.
When I learned about that, I thought that it would be some piece of information associated with a page that would have some sort of three-state value, e.g.:
Playing around with that a bit, I see that it doesn't work that way. The page-specific overrides don't appear to have that kind of durability. Asserting regular status of a Master layer:
ActiveDocument.MasterPage.Layers("MasterLayer 1").Visible
appears to blow away any page-specific overrides, document-wide, for the visibility of that layer. It appears to work the same way when such a change is made to the status of a Master layer via the UI through the "All pages, layers, and objects" view of the Object Manager.
This isn't really a problem for me, but I was working on something that does some "flipping of switches" for layer status, and was thinking of trying to preserve page-specific overrides. After looking at it more, I'm not so interested.
Eskimo said:This isn't really a problem for me, but I was working on something that does some "flipping of switches" for layer status, and was thinking of trying to preserve page-specific overrides. After looking at it more, I'm not so interested.
My interest in this perked up again later, and I did use this approach for determining when page-specific overrides of Master layers were present.
I also used it as part of a way to determine if a Master layer is an "odd pages" or "even pages" Master layer (I wasn't aware of a direct way of getting that information in VBA).
Thanks again, Shelby!