Hi,
I’m not familiar at all with Powershell but starting playing with it.
I’m currently runining a small script that converts MS Word docs into html.
The script works when I specify only the two first parms of the ‘saveAs2’ method.
But now, I want to specify another parm in 10th position of the ‘saveAs2’ method signature (encoding parm).
I red on the web that for unspecified parms I should set a type ‘Missing’. This is what I did so that my code is now like this:
function saveas-filteredhtml
{
$missing = [System.Type]::Missing
$opendoc = $word.documents.open($doc.FullName);
$opendoc.saveAs2([ref]"$htmlpath\$doc.html", [ref]$saveFormat, $missing, $missing, $missing, $missing, $missing, $missing, $missing, $missing, $missing, 65001, $missing, $missing, $missing, $missing, $missing);
$opendoc.close();
}
Unfortunatly I 'm now getting the following error when running my script :
Object reference not set to an instance of an object. At D:\temp\Winsights\ws\test\convertdoc-tohtml_2.ps1:17 char:3 + $opendoc.saveAs2([ref]"$htmlpath\$doc.html", [ref]$saveFormat ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [], NullReferenceException + FullyQualifiedErrorId : System.NullReferenceException
Not sure what the problem is.
Can anyone help on this ? Thanks in advance.
SibJm