#define wdExportFormatPDF 17 #define wdExportFormatXPS 18 #define wdExportOptimizeForOnScreen 1 #define wdExportOptimizeForPrint 0 #define wdExportAllDocument 0 &&Exports the entire document. #define wdExportCurrentPage 2 &&Exports the current page. #define wdExportFromTo 3 &&Exports the contents of a range using the starting and ending positions. #define wdExportSelection 1 && Exports the contents of the current selection. #define wdExportDocumentContent 0 &&Exports the document without markup. #define wdExportDocumentWithMarkup 7 && Exports the document with markup. local obj, FileIn, FileOut, ReadOnlyMode FileIn = 'D:\tmp\aaa.doc' FileOut = forceext(m.FileIn, 'pdf') ReadOnlyMode = .t. obj = createObject('Word.Application') =obj.Documents.Open(m.FileIn, , m.ReadOnlyMode) local OpenAfterExport OpenAfterExport = false =obj.ActiveDocument.ExportAsFixedFormat( ; m.FileOut, ; wdExportFormatPDF, ; m.OpenAfterExport, ; wdExportOptimizeForPrint, ; wdExportAllDocument, ; , ; , ; wdExportDocumentContent, ; true, ; true, ; 0, ; true, ; true ; ) =m.obj.Quit() obj = null