Copy link to clipboard
Copied
Hi everyone,
I am working on a small project which gets a list of image file locations from a DB and then I need to loop through the files and put the images onto the active photoshop document as a linked image.
The first part is easy enough, I found the photoshop scripting guide and cut and paste the Hello world example.
The only issue I have now is that I need to place the linked image on the active document.
I know that people prefer to program in Javascript to get this job done, but could someone kindly help me out with the VBscript. Thanking you kindly for your help.
Below is the code I have so far:
Dim appRef
appRef = CreateObject("Photoshop.Application")
Dim docRef
Dim artLayerRef
Dim textItemRef
docRef = appRef.ActiveDocument
'add the image --->>> this is a test file to place it as a linked file
Dim file As String
file = "D:\one_drive\OneDrive\English School\MES\Unit 3\feelings\images\real images\01 Happy.jpg"
'???? Now what??? ;(
' below is the hello world example
artLayerRef = docRef.ArtLayers.Add
artLayerRef.Kind = 2
' Set the contents of the text layer.
textItemRef = artLayerRef.TextItem
textItemRef.Contents = "Hello, World!"
The script listener plug-in can create both JS and VB code on Windows.
If VB scripting can play JS code, then it may be possible as a fallback to do the bulk of code in JS and call it from VB.
Copy link to clipboard
Copied
The script listener plug-in can create both JS and VB code on Windows.
If VB scripting can play JS code, then it may be possible as a fallback to do the bulk of code in JS and call it from VB.
Copy link to clipboard
Copied
I understand the concept of what the script listener should do. A bit like the Microsoft macro recorder.
I went to
https://helpx.adobe.com/photoshop/kb/downloadable-plugins-and-content.html#ScriptingListenerplugin
downloaded and then followed the instructions.
There was a problem but searching through some other sites.
I copied the
ScriptListener.8li file which was in
to C:\Program Files\Adobe\Adobe Photoshop CC 2019\Plug-ins\Automate
Then went into photoshop, Help --> system info and saw that ScriptListener was loaded.
Thank you very much this opens a world of possibilities for me.
Copy link to clipboard
Copied
I have the strangest feeling that I have played with this plugin like 15 years ago. I can't even remember what project it was. Maybe a scanning project. But yeah something very familiar about it. Thank you, Stephen so very much for your time and your answer. It has made this job so much easier.
Copy link to clipboard
Copied
After a day of working with the script listener. I got to say it is not worth the trouble. The VB code that it spits out is unusable. It is full of errors, it looks like the listener is just a no go. The only good thing I can say is I now have a more solid understanding of regular expressions in notepad++ other than that, disappointed.
Copy link to clipboard
Copied
Another two days of working with it.
The listener generates a chunk of code which it then puts between a REM ==========
it then dim's some of the same variables again. So you have to remove the dim statements.
I started seeing what each "chunk of code" was doing by doing: an action in ps and then checking the code generated, usually breaking when it made an execute action, maybe because the command code does not exist in the com??
Call objApp.ExecuteAction(idinvokeCommand, desc21, dialogMode) ' trips up here with error. In frustration, I just deleted the chunks of code that were breaking the code Eventually it worked
I just used brute force to try to solve the problem and it worked. If you get errors in chunks of code, why not just remove them and see if the end result is the same as what you want.