• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

659

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")

Votes

Translate

Translate
Adobe
Mentor ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

Reading your post made my head hurt....

Votes

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.

Votes

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
LEGEND ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

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

Votes

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).

Votes

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
LEGEND ,
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 ðŸ˜‰ 

Votes

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")

Votes

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