Source Code and Samples

Thursday 15 February 2007

Convert or export word documents to PDF

Description

Convert or export word documents to PDF

Data Source

#You need to install "Microsoft Office 2007 Add-in: Microsoft Save as PDF or XPS"
$word = new-object -ComObject "word.application"
$doc = $word.documents.open("C:\document.doc")
$saveaspath = [ref] "c:\document.pdf"
$formatPDF = [ref] 17
$doc.SaveAs($saveaspath,$formatPDF)
$doc.Close()

1 comment:

hooper said...

Can you post this with the part of SaveAs writed using the InvokeMember?. It lookslike now we must use it always.
Thanks