Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to use eval() with jsobject from VBA?

Guest
Jun 03, 2016 Jun 03, 2016

Hi!

I would like to use eval() from VBA using the jsobject, but I won't get the simplest eval("1+1") running because VBA stops with an error "Error 438: Object does not support method or property"

Any hints?  Is the brigde supporting eval?

I have the feeling the brigde sort of knows .eval, because the 'e' becomes capitalized in the VBA Debugger.

Still if you look up the Acrobat documentation of the JavaScript brigde there is no entry regarding eval.

Using the string to eval with or without extra quotes in the string, does not make a difference.

All relevant references are set.

This is my code:

Sub Adobe_TypeHello_and_TryEval()
Dim gApp As Acrobat.CAcroApp
Dim gPDDoc As Acrobat.CAcroPDDoc
Dim jso As Object
Dim strFileName As String

Dim ReturnVal
Dim strEval As String

strFileName = "c:\Temp\MyFile.pdf"

' does not matter which definition to use, both fail

strEval = "1+1"              'string is 1+1

' strEval = """1+1"""        'string is "1+1"

Set gApp = CreateObject("AcroExch.App")
gApp.Show

Set gPDDoc = CreateObject("AcroExch.PDDoc")
If gPDDoc.Open(strFileName) Then
    Set jso = gPDDoc.GetJSObject
    jso.console.Show
    jso.console.Clear
    jso.console.println ("Hello World!")
   
    'Code is working until here
    ReturnVal = jso.Eval(strEval) ' <-- Debugger stops here with error.
   
End If

End Sub

Thanks, Helmut

TOPICS
Acrobat SDK and JavaScript
1.4K
Translate
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 Employee , Jun 03, 2016 Jun 03, 2016

evalI() is a core JS method that you can’t call directly from the bridge – you can only call Acrobat methods from the bridge.

Translate
Adobe Employee ,
Jun 03, 2016 Jun 03, 2016

evalI() is a core JS method that you can’t call directly from the bridge – you can only call Acrobat methods from the bridge.

Translate
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
Guest
Jun 03, 2016 Jun 03, 2016
LATEST

I don't like the answer, but it looks like I have to accept it.

Have a nice Day!

Translate
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