Error in opening & repairing word through Powershell script

0

I am using the following powershell script code to open and repair corrupted documents.

            $word = New-Object -ComObject word.application
            $word.Visible = $true

            $word.documents.Open($Doc, $false, $false, $false, $false, $false, $false, $false, $false, $false, $false, $true, $true)

            #Log opening the file
            Log-Write -LogPath "$Logpathfilename" -LineValue "$DocLeaf  - Opening File"
            RepairProgress "Repair Progress $count of $totcnt " "Input box contains current file path and name, select and paste into Save As Dialog box if neccessary. Select the checkbox on repair outcome."  "$Doc"  
            # "Repair Outcome: $global:Outcome "
            Log-Write -LogPath "$Logpathfilename" -LineValue "$DocLeaf  - Repair Outcome:   $global:Outcome"`

I have also tried giving the command like below:

$word.documents.Open($inputFile, $refFalse,  $true, $null, $null, $null, $null, $null, $null, $null, $null, $null, $true, $null, $null, $null)

But the open command throws execption as "Exception calling "Open" with "13" argument(s): "Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))" At \AD\MyND_GL\Profile\jgeo1.AD\Desktop\Training\DO1.ps1:550 char:17 + $word.documents.Open($Doc, $false, $false, $false, $false, $fals ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ComMethodTargetInvocation"

.net
windows
powershell
ms-word
asked on Stack Overflow Jun 11, 2016 by Jomson

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0