lohriialo/photoshop-scripting-python

TypeError: 'Layers' object is not subscriptable

MFRS opened this issue · 1 comments

MFRS commented

I cannot select a layer, this is my code

` import win32com.client as win32
import os
from comtypes.client import GetActiveObject, CreateObject

try:
adobe_app = win32.GetActiveObject("Photoshop.Application")
except:
adobe_app = win32.gencache.EnsureDispatch('Photoshop.Application')
try:
# cd = adobe_app.Open(filepath)
cd = adobe_app.ActiveDocument
except:
cd = adobe_app.ActiveDocument
# cd = adobe_app.ActiveDocument
currentTextLayer = cd.Layers[0]
print(currentTextLayer)

`

Any suggestions?

Just got the same error. I solved it by replacing Layers['name'] by Layers.Item('name')