I have a DTS package that uses Active X to convert a word document to PDF. The package runs fine when called from the command line as DTSRun /S "(local)" /N "CreatePDF" /G "{53070739-28A1-4F56-AEE0-CFC7D89CF7E4}" /L "G:\DADocuments\Logfile.txt" /A "Document":"8"="G:\DADocuments\InvNarr09-05093.doc" /W "0" /E.
However, when I call this script using xp_cmdshell from a TSQL script it fails with ActiveX Scripting encountered a Run Time Error during the execution of the script.
I am running the script using the same user account that the sql server uses so I don't think it's a authentication issue. The only thing I can think of is that the API call to Word is failing. Can anyone find the problem? The Active X script is below:
Const WdPrintAllDocument = 0
Const WdDoNotSaveChanges = 0

Function DOC2PDF( sDocFile )

Dim fso ' As FileSystemObject
Dim wdo ' As Word.Application
Dim wdoc ' As Word.Document
Dim wdocs ' As Word.Documents
Dim sPrevPrinter ' As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set wdo = CreateObject("Word.Application")
Set wdocs = wdo.Documents
sDocFile = fso.GetAbsolutePathName(sDocFile)
sFolder = fso.GetParentFolderName(sDocFile)
sPrevPrinter = wdo.ActivePrinter
wdo.ActivePrinter = "novaPDF"
Set wdoc = wdocs.Open(sDocFile, , True )
wdo.ActiveDocument.PrintOut False
wdoc.Close WdDoNotSaveChanges
wdo.ActivePrinter = sPrevPrinter
wdo.Quit WdDoNotSaveChanges
Set wdo = Nothing
Set fso = Nothing

End Function

Function Main()

Dim sDocFile
sDocFile = DTSGlobalVariables("Document").value
Call DOC2PDF( sDocFile )
Set arguments = Nothing
set sDocFile = Nothing

Main = DTSTaskExecResult_Success

End Function