Hi all,
I am opening a PDF document fromm VBA excel. After opening document it should save the document as excel file or text file in one folder.
I am trying to do this with some code but not able to , pls help me thatnks.
Dim AcroApp As Acrobat.CAcroApp
Dim Part1Document As Acrobat.CAcroPDDoc
Set Part1Document = CreateObject("AcroExch.PDDoc")
Part1Document.Open ("Z:\EG MI Information\MIS\Requests\Req_156\NO.1.pdf")
Dim app As Object, avdoc As Object, pageview As Object
Set app = CreateObject("AcroExch.App")
Set avdoc = app.GetActiveDoc
app.MenuItemExecute ("SaveAs")
thanks
Abhijeet
Hi,
Usage of the JSObject is shown in the VB Samples folder in the Acrobat SDK in this folder
[Acrobat SDK Install location]\Version 1\InterAppCommunicationSupport\VBSamples
and look in these two samples to see how to use the JSObject
JSObjectAccessVB
JSOFindWordVB
There is also documentation on the JSObject here
http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/IAC_DevApp _OLE_Support.100.18.html
http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/IAC_DevApp _OLE_Support.100.13.html
Hope this helps
Malcolm
Dear BarlaeDc,
Thanks for your helpful information.
I need to install Adobe SDK first to gets examples. I tried using JSObject with some examples I found on Adobe site, but not able to activate menu. In below code "save as" is storing PDF file in machine code language inside text file. If you use "save as text" menu option from "file" main menu then it stores contents of pdf file into text file. and I want this to be done by code in VBA.
Dim Acroapp As CAcroApp
Set Acroapp = CreateObject("AcroExch.App")
Acroapp.Show
Dim avdoc As CAcroAVDoc
Set avdoc = CreateObject("AcroExch.AVDoc")
Dim jso As Object
Dim PDDoc As CAcroPDDoc
Set PDDoc = CreateObject("AcroExch.PDDoc")
PDDoc.Open ("Z:\EG MI Information\MIS\Requests\Req_156\NO.1.pdf")
Set jso = PDDoc.GetJSObject
PDDoc.execMenuItem ("Open")
jso.SaveAs "Z:\EG MI Information\MIS\Requests\Req_156\temp.txt"
Thanks
Abhijeet
Hi,
In the documentation for the saveAs function it has the following params
cPath The device-independent path in which to save the file.
cConvID (optional, Acrobat 6.0) A conversion ID string that specifies the conversion
file type.
cFS (optional, Acrobat 7.0) A string that specifies the source file system name.
bCopy (optional, Acrobat 7.0) A Boolean value which, if true, saves the PDF file
as a copy. The default is false.
bPromptToOverwrite (optional, Acrobat 7.0) A Boolean value which, if true, prompts the user if
the destination file already exists. The default is false.
In order to get a text file saved you need to specify the correct cConvID.
See the documentation for the valid convID's - http://livedocs.adobe.com/acrobat_sdk/10/Acrobat10_HTMLHelp/JS_API_Acr oJS.88.519.html
Please note the Acrobat SDK contains all the information and does not require much installing ( as it is a zip file(on windows) and a disc image (on Mac) it just needs extracted)
Regards
Malcolm
Dear BarlaeDC,
Thanks for your time & efforts. I think this will solve my task but when I use "save as" options it gives me error of 448, "Named argument not found", I checked for this and found that I have 2 versions of adobe oe is Adobe5 & another one is Adobe 7.
my code opens Adobe 5 version window first and then opens my document in this window. Now I am trying to open it in Adobe 7 version window. do you have any clue for it.
jso.SaveAs cPath:="Z:\EG MI Information\MIS\Requests\Req_156\teNO1.txt", cConvID:="com.adobe.acrobat.plain-text"
HI,
The Adobe Reader software can only save files if they have been enabled by the LiveCycle Reader Extension's Server or Acrobat Professional, if you have an enabled PDF file then the script should work, although please note the documentation which says.
Note: This method can only be executed during a batch or console event. See Privileged versus
non-privileged context for details. The event object contains a discussion of JavaScript events.
Please see the documentation for more information
Malcolm
North America
Europe, Middle East and Africa
Asia Pacific