Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using JSObject saveAs method with VBA

Status
Not open for further replies.

sglab

Technical User
Jul 29, 2003
104
US
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
 
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,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
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!
 
VBA has its own SaveAs method that may be different than the Java Script SaveAs method.

Google!

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
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)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top