Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi ,
Please could you help us for the below question .
We are trying to generate PDF and email it . Below is the Code .
Sub PDF
ActiveDocument.ClearAll
Dim FieldName
FieldName = "Month"
set mySelections = ActiveDocument.Fields(FieldName).GetPossibleValues(15)
Dim i
for i = 0 to mySelections.Count - 1
Dim FieldValue
FieldValue = mySelections.Item(i).text
ActiveDocument.Fields(FieldName).Select FieldValue
Print_PDF FieldValue, "ReportDocument - 1", "RP01"
Next
End Sub
Sub Print_PDF(Month, ReportName, ReportId)
' Designed for early bind, set reference to PDFCreator
Dim pdfjob
Dim sPDFName
Dim sPDFPath
'/// Change the output file name here! ///
sPDFName = ReportName & " - " & FieldValue
sPDFPath = "C:\PDFReports"
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
If .cStart("/NoProcessingAtStartup", True) = False Then
Exit Sub
End if
.cVisible = True
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
' Print the QlikView Report
ActiveDocument.PrintReport RP01, "PDFCreator"
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
ActiveDocument.GetApplication.Sleep 20
' in VBScript use WScript.Sleep(20)
Loop
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
ActiveDocument.GetApplication.Sleep 20
' in VBScript use WScript.Sleep(20)
Loop
pdfjob.cClose
Set pdfjob = Nothing
End Sub
' ActiveDocument.PrintReport RP01, "PDFCreator"
However we are getting an error for
ActiveX component can't create object: 'PDFCreator.clsPDFCreator'
however we have installed PDF creator 3.
Any help would be welcome .
Thanks
This is usually because the component has not been installed on the machine running the script or the registry information is invalid.
If it was installed, find the dll file containing the component (probably something like PDFCreator.dll) and use Regsvr32 to re-install the DLL into the registry. Google Regsvr32 for more information.
Thank you for a prompt help .
I will try the solution .
Thanks again