dcsimg
Results 1 to 6 of 6

Thread: Runtime Error in DTS Package

  1. #1
    Join Date
    Dec 2009
    Posts
    3

    Exclamation Runtime Error in DTS Package

    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

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Does it access remote file? If so, sql service account needs permission on it.

  3. #3
    Join Date
    Dec 2009
    Posts
    3
    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.

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Can't run interactive app from sql.

  5. #5
    Join Date
    Dec 2009
    Posts
    3
    So do you know an easier way to do this? Conversion on the fly?

  6. #6
    Join Date
    Sep 2002
    Posts
    5,938
    Try create sql job to run the package and start job in your sp.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •