# Database Discussions > MS SQL Server 7/MS SQL Server 2000 >  Runtime Error in DTS Package

## k6sly

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_

----------


## rmiao

Does it access remote file? If so, sql service account needs permission on it.

----------


## k6sly

The whole package copies the file from and remote server then runs the active x on the local copy.  I can see the local copy of the file and watch WINWORD.EXE load in the process manager, but then it does nothing until I kill Winword.  After I kill Winword the process completes.

----------


## rmiao

Can't run interactive app from sql.

----------


## k6sly

So do you know an easier way to do this?  Conversion on the fly?

----------


## rmiao

Try create sql job to run the package and start job in your sp.

----------

