SaveAs Error In VB Script To Make PDF From Docx

77 Views Asked by At

I run the code below in CMD window to convert a ~200 page .Docx file to a PDF:

  Set App       = CreateObject("AcroExch.App")
  Set AVDoc     = CreateObject("AcroExch.AVDoc")
  Set PDDoc     = CreateObject("AcroExch.PDDoc")
  AVDoc.Open    "C:\Users\rodger.beard\Desktop\DTS User Guide.docx", ""
  SET PDDoc     = AVDoc.GetPDDoc
  PDDoc.SaveAS  1, "C:\Users\rodger.beard\Desktop\DTS User Guide.pdf"
  AVDoc.Close   False
  PDDoc.Close
  App.Exit
  Set AcroApp   = Nothing
  Set AVDoc     = Nothing
  Set PDDoc     = Nothing

I get error 800A01B on line 6, PDDoc.SaveAs - "Object doesn't support this property or method"

1

There are 1 best solutions below

5
K J On

If the object does not support the method, then RTFM (Read the function manual).

You can use Adobe Acrobat to read all its PDF manuals especially in this case, that part may be working?

However Adobe no longer make their docs easy i.e they are NOT accessible just like their content? They are replaced by HTML !

So to find the best copy of acrobatsdk_iacguide.pdf (The one that you read before coding) may be here. https://opensource.adobe.com/dc-acrobat-sdk-docs/library/interapp/index.html

So the stated object is valid PDDoc but they fail to show what are the valid methods and I have to say the historic one was .Save now listed as https://opensource.adobe.com/dc-acrobat-sdk-docs/library/interapp/IAC_API_OLE_Objects.html#acroexch-pddoc So I suggest use or try without brackets

PDDoc.Save  (1, "C:\Users\rodger.beard\Desktop\DTS User Guide.pdf")

more details at https://opensource.adobe.com/dc-acrobat-sdk-docs/library/interapp/IAC_API_OLE_Objects.html#save