×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Using JSObject saveAs method with VBA

Using JSObject saveAs method with VBA

Using JSObject saveAs method with VBA

(OP)
Hi All,

I have a question for you and hope someone has already figured out the issue I am having.
I am trying to automate some tasks in Acrobat using VBA or VB, and while everything seems to be working, I can't convert PDF I am working with to JPEG, using method saveAs of JSObject.
Not only I get an "Application defined or object-defined error", VB editor keeps changing "saveAs" to "SaveAs" in the line that gives me the error and I am not sure if that is the reason.
I have looked on the Web, but haven't found one confirmed solution to this problem. So, if anybody could provide a line - or lines - of working VB code which invokes this method, I'd really appreciate it.
I am using something like this:

jso.saveAs "/D/Temp/" & fName & ", com.adobe.acrobat.jpeg"

or something like that:

jso.saveAs "D:\Temp\" & fName & ", com.adobe.acrobat.jpeg"

with the same result. And as I said, VBEditor changes "saveAs" to "SaveAs" all the time.

Thank you

RE: Using JSObject saveAs method with VBA

The JSObject SaveAs method has a number of arguments. Since this is a Microsoft Visual Basic for Applications forum, I doubt that many at this forum would have, at the tip of their tongue, the argument for saving a .pdf. You need to pose this question in a Java Script forum.

As for ‘VBEditor changes "saveAs" to "SaveAs" all the time’ that’s what good code editors do, giving you, the coder, feedback that you have a coded a valid command.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Using JSObject saveAs method with VBA

(OP)
Hello SkipVought,

thank you for your reply.
I will definitely post this question to javascript forum, too. Just thought that since this JSObject is what they call a "bridge" to Adobe Javascript, someone has had some experience with invoking this very method from VBA.
I mean, I've done some automation of Acrobat with JSObject before using VBA, but just can't figure out how to overcome these errors.

Have a great day and a happy New Year!

RE: Using JSObject saveAs method with VBA

VBA has its own SaveAs method that may be different than the Java Script SaveAs method.

Google!

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Using JSObject saveAs method with VBA

Better would be:

jso.saveAs "/d/temp/" & fName, "com.adobe.acrobat.jpeg"

However it probably still won't work as saveAs generally needs to be executed in what Adobe terms a "privileged security context", which is tricky to achieve from VBA. Since this is all related to Adobe's javascript API rather than generic javascript, I'd suggest you need to speak to Adobe experts, not javascript experts.

The following may also be useful, as it documents the saveAs details, defines what a 'safe path' is (which the call requires) and outlines privilege contexts (and which calls require them)

https://www.adobe.com/content/dam/acom/en/devnet/a...




Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close