Creating PDF files with Office 2007

From Lotus Script you can create a Word object – see this blog entry
Then you can fill it with data from your Notes Document and just save it as an PDF document

The easiest way to make the script, is to record a macro in Word and the convert the code to Lotus Script.

This line is from a Word macro, and show how to save the current document as a PDF file:

ActiveDocument.ExportAsFixedFormat OutputFileName:= “c:tempsample.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

To convert it to Lotus Script you need to translate all the constants to a value (and remove the parameter label).
To convert: In the Visual Basic editor, just right click on a constant – then select ‘Quick Info’ Or you can find all the constants in this database
Note – you can skip the last parameters if you don’t need them (using defaults)

The converted script will look like this

yourwordobject.ActiveDocument.ExportAsFixedFormat “c:tempsample.pdf”, 17, false, 0, 0

4 tanker om "Creating PDF files with Office 2007"

  1. What a great find! Can this work for Excel too? I've tried various attempts but nothing worked.

    I have a handle to the excel document called varExcelWorkbook but I can't figure out what I'm doing incorrectly, here are my attempts:
    varExcelWorkBook.ActiveDocument.ExportAsFixedFormat ExcelFileName$, 17, False, 0, 0

    varExcelWorkBook.ActiveWorkbook.ExportAsFixedFormat ExcelFileName$, 17, False, 0, 0

    varExcelWorkBook.ExportAsFixedFormat ExcelFileName$, 17, False, 0, 0

    varExcelWorkBook.Workbook.ExportAsFixedFormat ExcelFileName$, 17, False, 0, 0

    varExcelWorkBook.Document.ExportAsFixedFormat ExcelFileName$, 17, False, 0, 0

    varExcelWorkBook.Worksheets.ExportAsFixedFormat ExcelFileName$, 17, False, 0, 0

    varExcelWorkBook.Worksheet.ExportAsFixedFormat ExcelFileName$, 17, False, 0, 0

    Since I don't have an ActiveDocument I don't know what to reference for the call to ExportAsFixedFormat. Do you know what I could be missing?

  2. OK I tried this: varExcelWorkBook.ActiveSheet.ExportAsFixedFormat 17, ExcelFileName$
    and I get an OLEL automation object error but that's a far as I can get. hmmm…

  3. Found it! The constants are different…

    varExcelWorkBook.ActiveSheet.ExportAsFixedFormat 0, ExcelFilePath$ & {} & ExcelFileName$

    Thanks for the lead, it was super helpful.

Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *