Mutsop
asked on
PDFcreator issue with vbscript excel
Hi,
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?
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?
ASKER
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
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
Else
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
.cClearCache
End With
' Remember current active printer
sPrevPrinter = wdo.ActivePrinter
wdo.ActivePrinter = "PDFcreator"
' Open the Word document
Set wdoc = wdocs.Open(sDocFile)
wdo.ActiveDocument.Bookmarks("KlantGegevens").Select
'Paste chart at cursor position
wdo.Selection.Paste
wdo.ActiveDocument.PrintOut False, , , sTempFile
wdoc.Close WdDoNotSaveChanges
wdo.ActivePrinter = sPrevPrinter
wdo.Quit WdDoNotSaveChanges
Set wdo = Nothing
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cOption("UseAutosave") = 0
pdfjob.cClose
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
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'll try and fix that when I get back from work.
Regards
Regards
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..