Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
louiswinter
Partner - Creator
Partner - Creator

Print Reports Using Macro from Browser (AJAX) Not Working

All,

I am having an issue trying to generate reports (PDF) from a macro script.  The following is the setup:

1. A variable (vReportID)  gets set with the report ID (ie. RP01, RP02, etc).

2. A button is setup with an action of Print Report, Report ID =  '=vReportID' and Printer Name = 'PDF-XChange 3.0'.  When I manually click the button from the browser/Access Point, the report is generated correctly and it opens in a new tab.

3. Create a macro function to calculate the value of vReportID variable and set it, then find the button object and call Press method.  This works correctly and the button action(s) are called.  I added a second action to activate another sheet just so I know that the button is getting pressed.

The problem is that when I click the button manually it works correctly, but when the macro calls Press, the Print Report action either isn't being run or it is failing because no PDF is opened in a new tab.

Does anybody have any thoughts on what the issue could be?

Thanks in advance.

5 Replies
stabben23
Partner - Master
Partner - Master

marcus_sommer

Most macros won't work in ajax and shouldn't in general be avoided: Macros are Bad.

- Marcus

louiswinter
Partner - Creator
Partner - Creator
Author

According to the Print Sheet not working in ajax mode article, "Print Report" does work in AJAX.  When I click my print button manually it does print the report and open it in a new tab as expected.  And, the macro is running correctly as well because the 2nd action (just for debug purposes) that activates another sheet fires when the macro runs.  The issue is when the print button is pressed via the macro the "Print Report" (1st action) doesn't work but the 2nd action does.

The attached doc shows my issue.

Manually clicking on the "Generate Report RP##' button on Sheet1 works.

Clicking on "Generate Selected Report(s)" causes macro to run.  The macro sets a variable to the correct report ID and calls Press on the "Generate Report RP##" button.  This is what doesn't work in AJAX but does in the desktop.

marcus_sommer

It sounds that you mixed up different things which are not the same. The feature print sheet is different to print a report and firing a macro isn't the same then firing an action. If you really want to use macro-functionalities within the ajax-client you will need to use an extension for it and even this will be restricted.

Therefore I suggest to use the inbuilt report-feature which could very easy access multiple reports.

- Marcus

louiswinter
Partner - Creator
Partner - Creator
Author

Marcus,

I haven't said anything about "Print Sheet", the link Staffan posted refers to printing sheets so maybe that's where the confusion came in.  My issue is that I want to print a QV report using a macro, and it isn't working.  For testing I added a button to a sheet and set the action to "Print Report", this works correctly.  If I call the "Press" method of the same button from a macro, it doesn't work.  I've also tried to call "ActiveDocument.PrintReport" and this doesn't work in AJAX either.

Also, I have confirmed that the macro is running.  I attached a sample in another post which may explain my issue a little better.

Louis