OLE Automating (COM) InDesign 2023

Hi,

on Windows 11 (Xojo 2023r2) i’m trying to send a little InDesign Test-JavaScript from Xojo to InDesign with OLE Automation using the DoScript command. InDesign should then show an Alert-Info with “Hello” in it.

I know this worked before, but now it doesn’t. The following code produces an OLEException.

Dim obj As OLEObject
Dim result As Variant
Dim params(2) As Variant

obj = New OLEObject("InDesign.Application.2023", true)

result=obj.Value("version").StringValue

params(1)="alert(""Hello"");"
params(2)= 1246973031  //constant meaning the code is in InDesign-Javascript language
result = obj.invoke("DoScript", params)

The error:

Exception code 30477: Ungültiger Wert für Parameter “Language” der Methode “DoScript”. idScriptLanguage enumerator erwartet, aber nothing erhalten., (failed on “DoScript”)

I checked via VBA from Word with this code and it worked without issue. So i think there should be no issue in the DoScript-function-call and no system related issues. The function is called in the way described in the Xojo-documentation.

Private Sub CommandButton1_Click()
Dim script As String
Dim idVersion As String
Dim result As Variant

Set myInDesign = CreateObject("InDesign.Application.2023")

idVersion = myInDesign.Version

script = "alert(""Hello"");"
result = myInDesign.DoScript(script, 1246973031)

End Sub

Is there something i’m missing in Windows 11 or Xojo? Thanks for any help and ideas.

best, Thomas

I have the same problem.

The only solution I’ve found is to run the app as 32bit

1 Like

Hi Antonio, thank you for pointing this out to me. :grinning:

Maybe Xojo can fix it, but there is way to correct it in my sample, just by giving the parameter the needed unsigned 32-Bit-Integer. This way it runs in a 64-Bit-App:

Dim obj As OLEObject
Dim result As Variant
Dim params(2) As Variant
Const IdJavaScriptUINT32 as UInt32 = 1246973031 //constant for InDesign-Javascript-code

obj = New OLEObject("InDesign.Application.2023", true)

result=obj.Value("version").StringValue

params(1)="alert(""Hello"");"
params(2)= IdJavaScriptUINT32

result = obj.invoke("DoScript", params)

1 Like

Good to know!
it was so obvious, but I hadn’t thought of it

I will test it ASAP