Here we are using php COM(word.application) for converting the html to docx. But COM("word.application")->ActiveDocument->SaveAs($htmlfilepath, 16) function is giving the below mentioned error. Uncaught com_exception: Parameter 0: Type mismatch.
// WdSaveFormat: http://msdn.microsoft.com/en-us/library/office/bb238158%28v=office.12%29.aspx
static $wdSaveFormats = array(
'docx' => 16,
'html' => 10,
'rtf' => 6,
'txt' => 2,
'doc' => 0,
'pdf' => 17,
);
$newSaveFormat = 16;
if (preg_match('@\.(.{3,4})$@', $new, $arr)) {
if (isset($wdSaveFormats[$arr[1]])) {
$newSaveFormat = $wdSaveFormats[$arr[1]];
}
}
$rethrow = NULL;
try {
// Document.Enable long file name https://msdn.microsoft.com/en-us/vba/word-vba/articles/weboptions-uselongfilenames-property-word
$word->ActiveDocument->WebOptions->UseLongFileNames = true;
// Document.SaveAs: http://msdn.microsoft.com/en-us/library/office/bb221597%28v=office.12%29.aspx
// $new = 'Z:\data\reportPdf/1636634123sampl_test_2019programreport.docx';
**$word->ActiveDocument->SaveAs($new, $newSaveFormat);**
} catch (Exception $rethrow) {
// We still want to close the document.
}
Thanks in advance!