Friday, September 10, 2010


the other day we had a need to save an HTML file as DOCX. We are creating the HTML file using ConvertT0-HTML. The file contains data that needs to be saved in SharePoint and needs to be editable by others. We decided to save as a DOCX because those in management all have WORD installed but don't have a  Dedicated HTML editor. So here is the Code Enjoy.

!!! YOU MUST HAVE WORD 2007 or 2010 INSTALLED !!!!!

function ConvertTo-DOCX{

#int the the enum returns for DOCX format
$SaveAs = 16

#Create WORD object and perform conversion
$Word = New-Object -ComObject Word.Application
$OpenDoc = $Word.Documents.Open($In)

#stop all WORD instances
Get-Process | Where-Object { $_.Name -eq "WINWORD" } | Stop-Process -Force