Copy link to clipboard
Copied
I am having some difficulty with selecting the proper version of InDesign in my VB scripts.
Usually I use the connection string: CreateObject("InDesign.Application"), which will launch in whatever version is installed.
Now, one of my customers has installed version 6 along side with version 5.5, which means that I have to supply either: CreateObject("InDesign.Application.CS5.5") or CreateObject("InDesign.Application.CS6"), in order to get it to run on the proper version.
What I don't understand is why the script doesn't start within the version of InDesign that it is activated from. If I use the connection string: CreateObject("InDesign.Application"), and I start it from within InDesign version 6 (from the script menu), why does it launch version 5.5 and try to run the script there? Why does it not run inside the InDesign application that launched it?
It quickly becomes a mess to have to modify scripts whenever people install new versions of InDesign, so is there any way to ensure that a VB script is always run within the InDesign application that launched it, regardless of what other versions people might have installed?
Copy link to clipboard
Copied
you can use WMI to have a peak at all the ID processes.
here I have both CS4 and CS5 running, hopefully only one version should be running at a time, and we can use the ExecutablePath property to get the version (CS4 for instance) from it.

Dim WMI, Col, Ob, S2
Err.Clear
On Error Resume Next
Set WMI = GetObject("WinMgmts:")
If (Err.number <> 0) Then
MsgBox "Error creating WMI object. Error: " & Err.Number & " - " & Err.Description
WScript.quit
End If
'-------------- processes ------------------------------------
Set Col = WMI.ExecQuery( _
"SELECT * FROM Win32_Process" & _
" WHERE Name = 'indesign.exe'",,48)
S2 = S2 & " Process Info:" & vbCrLf & vbCrLf
For Each Ob in Col
S2 = S2 & "Caption: " & Ob.Caption & vbCrLf
S2 = S2 & "ExecutablePath: " & Ob.ExecutablePath & vbCrLf
S2 = S2 & "ProcessID: " & Ob.ProcessID & vbCrLf & "__________________________" & vbCrLf & vbCrLf
Next
msgbox S2
Set Col = Nothing
Set WMI = Nothing
MsgBox "Done."
Copy link to clipboard
Copied
Actually people can have both version started at the same time, so that is no good. What I want is for the script to be run within the InDesign instance that launched it. As far as I know, this in how it works in JavaScript, so I don't see why the same thing can't be done for VBScript.
Microsoft can figure out how to do it. If you take Mircosoft Words for instance, and make a macro in there, then it doesn't start up another Word instance when you activate the macro. It runs within the same instance of Word. This is what I would like in InDesign too.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more