Forum Discussion
nothing at all?
It's really impressive how SmartBear encourages users to use the forum.... but doesn't use the forum to help users
- HKosova10 years ago
Alumni
Hi Leandro,
All Microsoft Office products provide an API in the form of COM objects that let you automate all kinds of things, including saving files to a different format. Word's COM object is Word.Application. You can use the Application.Documents.Open(FileName) method to open a file and the Document.SaveAs(FileName, FileFormat) method to save it to a specific format. Here's an example:
// JScript function Test() { RTF2PDF("C:\\Work\\Example.rtf", "C:\\Work\\Example.pdf"); } function RTF2PDF(RTFFileName, PDFFileName) { var wdFormatPDF = 17; var oWord = Sys.OleObject("Word.Application"); var oDoc = oWord.Documents.Open(RTFFileName); oDoc.SaveAs(PDFFileName, wdFormatPDF); oDoc.Close(); oWord.Quit(); }
This works for me in Word 2010.
Helpful links:
- leandropoblet10 years agoFrequent Contributor
This is exactly what I needed. Thank you!
- Colin_McCrae10 years agoCommunity Hero
Slightly off topic I guess ....
But I always though you Printed, rather than Saved, from Word to generate a PDF file?
(Just thinking out loud. And it's a long time since I've had to do it.)
:smileyhappy: