PDFcreator issue with vbscript excel


I made a program in excel which would copy paste client info into a word doc and pdf it automaticly (and save it). Everything worked great till a few days ago.

Before word would open, and get pdf'ed automaticly using pdfcreator, you could see a tray icon appearing first in red, then green while after it dissapeares.

Now pdf creator just stay reds, nothing is included in the list except all options are saved.

Fyi I change the config of pdfcreator in vbscript so it saves the file in a specific folder... That works.

Any ideas, why suddenly it stopped working?
Who is Participating?
I really don't use VBA much, but as it is rooted in VBScript I will point out that this line:

      Dim pdfjob As PDFCreator.clsPDFCreator

Won't work.  You need to change it to

Dim pdfjob

Unless you are using Visual Basic.Net and this is in the wrong forum.
Unless you want people to just guess, it might be a good idea to start by posting your code, and then describing, in great detail, what changes took place when the problem began.

A sample spreadsheet might not hurt, either, so that we have correct data to work with.  There could be something wrong in the source data that the PDF creator doesn't like..
MutsopAuthor Commented:
Well the point is that I haven't changed my code.
It worked like a few days ago, then suddenly nothing.

I copied the files onto the server and checked with another pc and it works.

The code however isn't well written, I still need to clean it :D
Function DOC2PDF(sDocFile, sPDFFile)
      Dim fso ' As FileSystemObject
      Dim wdo ' As Word.Application
      Dim wdoc ' As Word.Document
      Dim wdocs ' As Word.Documents
      Dim sPrevPrinter ' As String
      Dim sPDFName As String
      Dim sPDFPath As String
      Set fso = CreateObject("Scripting.FileSystemObject")
      Set wdo = CreateObject("Word.Application")
      wdo.Visible = True
      Dim pdfjob As PDFCreator.clsPDFCreator
      Set pdfjob = New PDFCreator.clsPDFCreator
      pdfjob.cStart ("/NoProcessingAtStartup")
      sPDFPath = "Z:\Offertes\" & cbx_offertefolder.Value
      Dim Klant As String
        If txt_bedrijf.Value = "" Then
            Klant = txt_naam.Value & " " & txt_voornaam.Value
            Klant = txt_bedrijf.Value
        End If
      sPDFName = Klant & " " & sDocFile & ".pdf"
      Set wdocs = wdo.Documents
      sTempFile = fso.GetSpecialFolder(TemporaryFolder) + "\" + fso.GetTempName()
      sDocFile = "Z:\Templates\Formulier\" & sDocFile
      sFolder = "Z:\Templates\Formulier\"
      If Len(sPDFFile) = 0 Then
        sPDFFile = fso.GetBaseName(sDocFile) + ".pdf"
      End If
      If Len(fso.GetParentFolderName(sPDFFile)) = 0 Then
        sPDFFile = sFolder + "\" + sPDFFile
      End If
      With pdfjob
            '/// Change the output file name here! ///
            .cOption("UseAutosave") = 1
            .cOption("UseAutosaveDirectory") = 1
            .cOption("AutosaveDirectory") = sPDFPath
            .cOption("AutosaveFilename") = sPDFName
            .cOption("AutosaveFormat") = 0    ' 0 = PDF
      End With
      ' Remember current active printer
      sPrevPrinter = wdo.ActivePrinter
      wdo.ActivePrinter = "PDFcreator"
      ' Open the Word document
      Set wdoc = wdocs.Open(sDocFile)
        'Paste chart at cursor position
      wdo.ActiveDocument.PrintOut False, , , sTempFile
      wdoc.Close WdDoNotSaveChanges
      wdo.ActivePrinter = sPrevPrinter
      wdo.Quit WdDoNotSaveChanges
      Set wdo = Nothing
        Do Until pdfjob.cCountOfPrintjobs = 1
        pdfjob.cPrinterStop = False
        'Wait until PDF creator is finished then release the objects
        Do Until pdfjob.cCountOfPrintjobs = 0
      pdfjob.cOption("UseAutosave") = 0
      Set pdfjob = Nothing
End Function
Private Sub btn_printpdfofferte_Click()
    Dim sDocFile As String
    Dim sPDFFile As String
    Call CopyEntries(Me)
    For I = 0 To lst_offerte.ListCount - 1
        If lst_offerte.Selected(I) Then
            sDocFile = lst_offerte.List(I)
            Call DOC2PDF(sDocFile, sPDFFile)
        End If
End Sub

Open in new window

MutsopAuthor Commented:
I'll try and fix that when I get back from work.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.