viewpoint-particle

Author Topic: Word save as PDF  (Read 66 times)

domvalle@comcast.net

  • Newbie
  • *
  • Posts: 13
Word save as PDF
« on: November 05, 2019, 06:20:38 pm »
Trying to get this right... ExportAsFixedFormat does not work...

file = "C:\temp\testdom.docx"
App = ObjectOpen("Word.Application")
Docs = App.Documents
Doc = Docs.Open(file)
Doc.ExportAsFixedFormat(::OutputFileName="C:\temp\testdom.pdf", ExportFormat=wdExportFormatPDF, OpenAfterExport=False)
Doc.Close()
App.Quit()

ObjectClose(Doc)
ObjectClose(Docs)
ObjectClose(App)

pause("Word Convert", "Complete")

exit

Actual Word Macro shows this:
Sub Macro1()
'
' Macro1 Macro
'
'
    ActiveDocument.ExportAsFixedFormat OutputFileName:="C:\temp\testdom.pdf", _
        ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
        wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
        Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
        CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
        BitmapMissingFonts:=True, UseISO19005_1:=False
    ChangeFileOpenDirectory "C:\temp\"
End Sub

any suggestions?, thanks!

stanl

  • Pundit
  • *****
  • Posts: 948
Re: Word save as PDF
« Reply #1 on: November 06, 2019, 02:34:36 am »
Just a quick guess but...


has wdExportFormatPDF been previously assigned in your script

might want to use @FALSE

domvalle@comcast.net

  • Newbie
  • *
  • Posts: 13
Re: Word save as PDF
« Reply #2 on: November 06, 2019, 03:17:29 am »
you are correct, I have not.
I don't know what wdExportFormatPDF should be.
I will try to find out...

domvalle@comcast.net

  • Newbie
  • *
  • Posts: 13
Re: Word save as PDF
« Reply #3 on: November 06, 2019, 03:52:12 am »
ok, looks like wdExportFormatPDF = 17
but still fails, must be some syntax issue?

domvalle@comcast.net

  • Newbie
  • *
  • Posts: 13
Re: Word save as PDF
« Reply #4 on: November 06, 2019, 03:57:40 am »
Oh, actually getting an 'Assignment not legal here. (Use == for equality testing) here
-->Doc.ExportAsFixedFormat(OutputFileName="C:\temp\testdom.pdf", ExportFormat=wdExportFormatPDF, OpenAfterExport=TRUE)
...hmmm

domvalle@comcast.net

  • Newbie
  • *
  • Posts: 13
Re: Word save as PDF
« Reply #5 on: November 06, 2019, 04:29:58 am »
OK, this line worked to save!
Doc.SaveAs("C:\temp\testdom.pdf",wdExportFormatPDF)
duh!