Printing Word Doc via Scheduled Task

D

David

Hi

I am attempting to print a Word document via a vbscript which is triggered
via a scheduled task on a Windows Terminal Server. The scheduled task is
configured to run daily.

The process works perfectly when the service account configured to open and
print the document via the vbscript has an active logon session to the
Terminal Server.

However when the service account does not have an active logon session, the
task triggers the script which opens the document and prints, but the
document remains open thus meaning any additional attempts to open the
document will advise that the document is locked and the process will fail.
This also means that the document cannot be edited.

The script is as follows:

set WshShell = WScript.CreateObject("WScript.Shell")
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("path to docmuent")

objDoc.PrintOut()
WScript.Sleep 2500
objWord.Quit
WScript.Sleep 2500
WshShell.SendKeys "n"

Any advice regarding a solution to this problem or an alternative solution
would be greatly appreciated.
 
R

Robert M. Franz (RMF)

Hello David
I am attempting to print a Word document via a vbscript which is triggered
via a scheduled task on a Windows Terminal Server. The scheduled task is
configured to run daily.
[..]

you've hit ("courtesy" of Microsoft :)) a general purpose/enduser
newsgroup. Your best bet is to reach the automation gurus, and they tend
to sit in the .word.vba* groups.

0.2¢
Robert
 
D

David

Thanks Robert

I will try there instead...

David

Robert M. Franz (RMF) said:
Hello David
I am attempting to print a Word document via a vbscript which is triggered
via a scheduled task on a Windows Terminal Server. The scheduled task is
configured to run daily.
[..]

you've hit ("courtesy" of Microsoft :)) a general purpose/enduser
newsgroup. Your best bet is to reach the automation gurus, and they tend
to sit in the .word.vba* groups.

0.2¢
Robert
--
/"\ ASCII Ribbon Campaign | MSFT |
\ / | MVP | Scientific Reports
X Against HTML | for | with Word?
/ \ in e-mail & news | Word | http://www.masteringword.eu/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top