How to select a layer by name using VB (VBA from Office)?

Community Beginner ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

I am writing a code in VBA to replace a text on a few layers in PSD file and so far I can open PSD, but I cannot select a layer by name. All that I found is that I should use PSDoc.ArtLayers.GetByName("Layer Name"), but that "GetByName" does not exists in VBA.

Then I tried looping through layers and then I found out there is no Layers.Length - that "Length" does not exists.

Basically I have group "Text" and layer "Layer 1". This is the closest I get, but this does not work:
PsDoc.ActiveLayer = PsDoc.ArtLayers.GetByName("Layer 1")

Does anyone knows how to select a layer by name using VBA (or VB)?

TOPICS
Actions and scripting, SDK, Windows

Views

158

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Community Beginner , Apr 15, 2021 Apr 15, 2021
Found it, by trials and errors: PsApp.ActiveDocument.ActiveLayer = PsDoc.LayerSets.Item(1).Layers("Layer 1")

Likes

Translate

Translate
Engaged ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Reading your post made my head hurt....

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Very usefull comment. VERY. Congratulations.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

For Photoshop there's vbscript (VBS), not VB(A).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

My question was about VBA, please read the full post, not just title, and I found the solution (last message in this thread).

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

LATEST

My point is this forum is for as, vbs and js than python, c or vba, and I didn't miss your post 😉 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Found it, by trials and errors:

 

PsApp.ActiveDocument.ActiveLayer = PsDoc.LayerSets.Item(1).Layers("Layer 1")

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines