I'm currently developing a script that takes a Word document, opens it up in Word, and then prints the Word file as a PDF. Everything works great when run manually either on my machine or the server. The problem comes in when I attempt to run it as a scheduled task.
One of the requirements is that this should be done nightly without any intervention. When I set up a schedule task to do this and set the security options to "Run only when user is logged on" everything works fine. Problem is, this has to be run with or without someone being logged on. If I set the task to "Run whether user is logged on or not", the script fails on the following line:
wordDoc = MSWord.Documents.Open(ref fileToConvert, ref refFalse, ref refTrue,
ref RN, ref RN, ref RN, ref RN, ref RN,
ref RN, ref RN, ref RN, ref RN, ref RN,
ref RN, ref RN, ref RN);
MSWord.Documents.Open()
works, but returns null.
This task is running on Windows Server 2008 with Office 2007.
Is there another approach I should be taking for this?