Word save as PDF

Started by domvalle@comcast.net, November 05, 2019, 06:20:38 PM

Previous topic - Next topic

domvalle@comcast.net

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

Just a quick guess but...


has wdExportFormatPDF been previously assigned in your script

might want to use @FALSE

domvalle@comcast.net

you are correct, I have not.
I don't know what wdExportFormatPDF should be.
I will try to find out...

domvalle@comcast.net

ok, looks like wdExportFormatPDF = 17
but still fails, must be some syntax issue?

domvalle@comcast.net

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

OK, this line worked to save!
Doc.SaveAs("C:\temp\testdom.pdf",wdExportFormatPDF)
duh!