$ErrorActionPreference = 'Stop' $word = New-Object -ComObject Word.Application $word.Visible = $false try { $doc = $word.Documents.Open('E:\Desktop\xst_files\test\QaAutomationHub\output\docx_check\check.docx', $false, $true) $doc.SaveAs2('E:\Desktop\xst_files\test\QaAutomationHub\output\docx_check\check_html.html', 10) $doc.Close($false) Write-Output 'HTML-OK' } finally { $word.Quit() }