Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
Not applicable

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

You should use the report variable instead of the chart object here.

Highlighted
Not applicable

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

I'm sorry, but I'm kind of new to QlikView. Are you saying that I have to create a report to send to a pdf? How do you send graphs and barcharts to a pdf file?

Highlighted
Not applicable

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

> How do you send graphs and barcharts to a pdf file?

By creating a report with your graphs / charts in it !

Highlighted
Not applicable

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

I created a report and put 'CH02' on the report. I changed my trigger to use 'RP01' and it still won't save the PDF file.

Thanks for your help.

Kathy

Highlighted
Not applicable

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

Good day Kathy,

Use this simplified macro :


sub ExportToPDF
ActiveDocument.GetApplication.WaitForIdle

set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegWrite "HKCU\Software\QlikViewPDF\OutputFile", "C:\tmp\file.pdf", "REG_SZ" 'change the path
WSHShell.RegWrite "HKCU\Software\QlikViewPDF\BypassSaveAs", "1", "REG_SZ"

ActiveDocument.PrintReport "RP01", "QlikViewPDF", false
set WSHShell = nothing

end sub


and make sure your current local security is "allow system access".

Also verify that "QlikViewPDF" is an existing printer in your setup.

Be aware that this macro will not be triggered when the reload comes from QV server / QV publisher.

Highlighted
Not applicable

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

I had to add some sleep commands but I got it to work on my laptop which has XP installed. When I run it on our QlikView server (has Windows 2008 installed), it pops up the Save as box, and won't save the file, or if it does, it overwrites the same file over and over. I've read in other posts, that this won't work with Windows 2007, so I'm guessing it won't work for Windows 2008 either. Does QlikView have a solution to this. I can't seem to find any thing about this on the actaul sight.

Thanks,

Kathy.

Highlighted
Not applicable

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

The behavior you describe looks like you are using "QlikViewPDF version 9".

I've never succeded to set the parameters with registery keys with this version.

Try to use the 7.52 version, it should work.

Highlighted
Not applicable

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

We are using the 7.52 version. The server is a Windows 2008 64-bit OS. We changed the QlikViewPDF preferences to save to a default path and to use the job name and the 'save as' box doesn't pop up, but, it overwrites the file QlikView Printing.pdf each time (doesn't use the file name populated in the registery key). We did have "QlikViewPDF version 9" installed but we uninstalled it. Do you think there is residual files that didn't get cleaned up with the uninstall? If so, do you know what to look for?

Thanks,

Kathy

Highlighted
Not applicable

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

We changed the QlikViewPDF preferences to save to a default path and to use the job name and the 'save as' box doesn't pop up, but, it overwrites the file QlikView Printing.pdf each time


This looks like to be the behavior of the v9.

How did you "changed the QlikViewPDF preferences to save to a default path" ?

Here is the QlikViewPDF v7.52 properties page :

You notice there is no option to change anything usefull...

Here is the v9 properties page :

with the "Save" panel I think you used :

Here you can change some parameters (default folder, ...)... BUT it's not the printer you want to use !

Recap :
- with v9, you can change preferences in your control panel, but I've never succeded to change preferences by modifying the registry
- with v7.52, you don't have many preferences in your control panel, but you can change parameters by modifying the registry

Be sure that in your code, you are calling the right printer.


ActiveDocument.PrintReport "RP01", "QlikViewPDF", false