Word Automation

  • Follow


Hi,

I have a question about the automation of Word objects. With following code 
I open a word document:

$services = @(Get-Service)
$msWord = new-object -ComObject "word.application"  -ea silentlycontinue
$wordDoc = $msWord.Documents.Open("somedocument.doc")

....do something with the worddoc....

$msWord.Documents.Close()
$msWord.Quit()

With the PS script, I want to make a batch processing over a lot of 
documents. In some cases, a word file might be used by another user or there 
might be a further inquiry with a dialogbox. In this case, the script will 
wait for an user interaction. Is it possible to make a automation for those 
user inquiries?
Thanks a lot for helping me! :-)

Bye, Volker
0
Reply Utf 5/5/2010 11:56:01 AM

> With the PS script, I want to make a batch processing over a lot of
> documents. In some cases, a word file might be used by another user or 
> there
> might be a further inquiry with a dialogbox. In this case, the script will
> wait for an user interaction. Is it possible to make a automation for 
> those
> user inquiries?
> Thanks a lot for helping me! :-)

Are you able to provide a bit more details?  I'd like to think you can do 
anything...

Marco 

0
Reply Marco 5/5/2010 12:06:26 PM



"Marco Shaw [MVP]" wrote:

> > With the PS script, I want to make a batch processing over a lot of
> > documents. In some cases, a word file might be used by another user or 
> > there
> > might be a further inquiry with a dialogbox. In this case, the script will
> > wait for an user interaction. Is it possible to make a automation for 
> > those
> > user inquiries?
> > Thanks a lot for helping me! :-)
> 
> Are you able to provide a bit more details?  I'd like to think you can do 
> anything...
> 
> Marco 
> 
Hi Marco,

in detail, we want to check every word document for the used template path. 
A lot of documents are containing a private network path. If you open this 
document outside the intranet, it takes several minutes. So, we want to check 
for the path with:

....
				$template = $wordDoc.AttachedTemplate.FullName 
				if ($template.Contains("`\`\")) {
....
If there is a reference to a private networt path, we change and save the 
file.
The problem is now, that a lot of files require a user interaction while 
opening the file with powershell. For example, if another user has the file 
in use, a dialog box will appear and the powershell script will stop and 
wait. I want to know, how it is possible to handle those user interactions 
with powershell. Do you need more details?

Best wishes!

Volker

0
Reply Utf 5/6/2010 8:57:01 AM

2 Replies
407 Views

(page loaded in 0.093 seconds)

Similiar Articles:
















7/20/2012 3:02:07 AM


Reply: