VBscript place linked image

Explorer ,
Mar 14, 2022 Mar 14, 2022

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

TOPICS
Actions and scripting

Views

141

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

Adobe Community Professional , Mar 14, 2022 Mar 14, 2022
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.

Likes

Translate

Translate
Adobe Community Professional ,
Mar 14, 2022 Mar 14, 2022

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.

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
Explorer ,
Mar 15, 2022 Mar 15, 2022

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.

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
Explorer ,
Mar 15, 2022 Mar 15, 2022

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.

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
Explorer ,
Mar 16, 2022 Mar 16, 2022

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. 

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
Explorer ,
Mar 18, 2022 Mar 18, 2022

Copy link to clipboard

Copied

LATEST

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.

 

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