VB.NET and Photoshop - Some existing layers aren't accessible
I've written a VB.NET app (that hooks into Photoshop's COM) that automates setting up mock up images. The only way I could find to gain access to specific layers/art layers was to pre-format the layer names with "Layer 0", "Layer 1", etc.
For example:
proofArtLayer = curDoc.ArtLayers.Item("Layer 1")
printArtLayer = curDoc.ArtLayers.Item("Layer 2")
Now, I'm trying to work on a project that manipulates files from other people and the layer names are not pre-formatted. I've tried the previously mentioned method and it's very hit-or-miss if it works or not (usually gives 'Element doesn't exist' runtime error). My understanding was that Photoshop saw the layers as "Layer 0", "Layer 1", etc despite their actual names (what the documentation refers to as its 'itemKey').
The VB Script doc says:
ArtLayers
Method | Parameter Type | Returns | What it does
Item (ItemKey) | Number (Long) | ArtLayer | Gets an element from the ArtLayers collection.
I've tried passing numbers (to iterate through artLayers like an array), but that throws an illegal argument error.
I'm so confused. I would think there would have to be some way of directly accessing and cycling through layers without pre-formatting the layer names manually (which kind of defeats the point of automating). I just need someone more knowledge and experience to point me in the right direction.
Thank you so much for any help you can give!
