How to reference Layers by NameU

Started by cannopa, May 12, 2012, 01:33:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cannopa

I understand it's best practice to use the universal names programatically rather than the local names but I'm having trouble referencing Layers by their NameU. As in ...

This works
Set objLayer = ThisDocument.Pages(1).Layers("MyLocalName")

But this doesn't
Set objLayer = ThisDocument.Pages(1).Layers("MyUniversalName")

Would I be right in accepting the best solution is to cycle through the layer collection looking for a match on .NameU to find the layer I want ?

Many thanks

Paul Herber

The syntax .Layers("MyLocalName") is a bit of a shortcut, it should really be
.Layers.Item("MyLocalName")
then for universal names
.Layers.ItemU("MyUniversalName")
Electronic and Electrical engineering, business and software stencils for Visio -

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

cannopa

D'Oh ! Thanks Paul.

I should have spotted that one but it got lost in all the other combinations of item, itemU, name and nameU. I'd thought Item only took the index number.

Rgds
Peter