Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Create PDF via macro works once, then doesn't produce .pdf file again

I am using QlikView 9. I've tried the following code on a Windows 2008 server and a XP desktop. I'm using the PDF writer from QlikView 7.52. My coworker has used the Xchange 3.0 as well and gets the same results. I got most of this code from Posts on this forum. This is a trigger OnPostReload. Whether I do a reload or a debug, it seems to stop on the statement: ActiveDocument.PrintReport "CH02", "QlikViewPDF".

sub Exports

set obj = ActiveDocument.GetSheetObject("CH02")

set val = ActiveDocument.Fields("Mn.wk.ctr_VAPLZ").GetPossibleValues

for i=1 to val.Count-1

ActiveDocument.Fields("Mn.wk.ctr_VAPLZ"). Select val.Item(i).Text

set obj = ActiveDocument.GetSheetObject("CH02")

Set WSHShell = CreateObject("WScript.Shell")

fln = "C:\data\myreport"&val.Item(i).Text&".pdf"

RegKey = "HKEY_CURRENT_USER\Software\QlikViewPDF"

WSHShell.RegWrite RegKey & "BypassSaveAs", 1

WSHShell.RegWrite RegKey & "OutputFile", fln

ActiveDocument.GetApplication.Sleep 2000

ActiveDocument.PrintReport "CH02", "QlikViewPDF"

ActiveDocument.GetApplication.Sleep 2000

WSHShell.RegWrite RegKey & "BypassSaveAs", 0

WSHShell.RegWrite RegKey & "OutputFile", ""

Set WSHShell = nothing

next

ActiveDocument.Fields("Mn.wk.ctr_VAPLZ").Clear

end sub



Thank you,

Kathy





12 Replies
Not applicable
Author

I can't seem to paste a screen shot in my post so I will try to explain. The 'Preferences' file that I am talking about is located on the server under Program Files (x86) -> QlikView -> QlikViewPDF. If you double click on the 'Preferences' file you will get a screen that has several checkboxes. In the Output Options section, we checked the 'Use default folder location' and filled in the location and we checked 'Use print job name to save PDF file under default folder automatically' and that stopped the pop up 'save as' box, but it overwrites the QlkView Printing.pdf instead of using the name in the registry for the output file.

I looked in the Devices and Printers on the server, and we only have QlikViewPDF installed. We do not have the XChange 3.0 in the list.

Kathy

Not applicable
Author

Hi,

In order to automate your PDF printing, please trigger your macro in 'OnOpen' instead of 'OnPostReload' & in this case you need to call your reload command 2 times. 1st time is to reload data, 2nd time is to trigger 'OnOpen' to print pdf.

It seems that 'OnPostReload' to print pdf will not work at all for those batch reload.

This issue has been reported by someone previously.

I am not sure whether this one has been resolved, but 2 time reload & print report on 2nd 'OnOpen' seems to be the only solution.

The 'OnPostReload' will never work, if you are trying to trigger it using batch command.

best regards

mingming

Not applicable
Author

Hi,

i had the same problem and I use this:

  

'Centrale macro
sub ReloadExportSend
ExportPDF
ActiveDocument.Reload

ExportPDF

ActiveDocument.save
ActiveDocument.GetApplication.Quit
end sub

sub ExportPDF
dim myFSO, myFile, myFileCopy 'Settings for the filecopy
Set myFSO = CreateObject("Scripting.FileSystemObject") 'Settings for the filecopy
ActiveDocument.PrintReport "RP01" , "PDF-XChange Printer 2012" , false 'Print the report via the PDF-printer
Set myFileCopy = myFSO.GetFile("C:\TempPrintQlikView\QlikView Printing.pdf") 'Which document has to be renamed
ActiveDocument.GetApplication.Sleep 10000
myFileCopy.Copy "L:\Rapportages\Logistics\DeliveryPerformance.pdf" ' recall the PDF file

end sub

it works fine by me!

Frank