I'm trying to use PHP COM to save docx files as html using Word. I am using a Windows installation with apache 2.2.x and PHP5. Office 2007 is installed.
Using the following code to list fileconverters:
$word = new COM('word.application') or die('Unable to instantiate word.');
foreach($word->FileConverters as $converter) {
var_dump($converter->ClassName);
}
However, I only get the following output:
string(6) "wks632"
string(7) "Recover"
string(11) "WrdPrfctDos"
string(13) "WordPerfect6x"
string(14) "MSWinWrite.wpc"
string(11) "MSWord6.wpc"
string(11) "MSWorksWin6"
This microsoft document says there should be a 'HTML' option available. It may be for an older version of Office though, I am not sure!
Anyone know what's going on? Is it even possible to do this with my current setup?
The objects that are listed in the FileConverters
are only the converters that are using Word's RTF converter interface.
Word has additional built-in support for a variety of file formats which are described by the WdSaveFormat
enumeration. To save as HTML, you could use the following code:
<?php
$word->Documents->Add();
$word->ActiveDocument->Range->Text = "Hello World!";
$word->ActiveDocument->SaveAs('document.html', 8);
$word->Quit();
?>