Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Opening a Word document by using Open method of Documents collection

$
0
0

Hello,

Could somebody please help me figure out how to properly open a Word document?

$word = New-Object -ComObject "Word.application"
$sourceFile = "C:\Users\Admin\AppData\Local\Temp\WordCNV\" + $fullname
$document = $word.Documents.Open([ref]$sourceFile)

The script above doesn't work because it seems like Documents collection is empty and I can't call the Open method for a Null value.

How do I properly do that?

Thank you.


Well this is the world we live in And these are the hands we're given...


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>