Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
kdmarkee221
Contributor III
Contributor III

Macros in NPrinting Excel Reports

I have a scenario where I have an Excel report based on a group_id field in the Cycle, ans that Excel report needs to conditionally hide/show certain worksheets within it based on the value of group_id.  I've been experimenting with a macro but am not getting the desired result, that is, all worksheets show up for all group_ids after I run my Publish task.  I see this note online about how the macros "are not executed" and am wondering what this means.....  does the user have to actually execute the macro?  Is there anyway to get something like this to work?  I do not think a paging solution will work because I mix and match QlikView charts on one Excel worksheet at times.

"Qlik NPrinting can generate Excel reports in .xlsm format. Visual basic macros can be created inside the Qlik NPrinting Designer and will be available in the final report. However, they are not executed."

Labels (2)
1 Solution

Accepted Solutions
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

hi Kris,


Its simple - yes - nprinting does not execute macro during report generation. That macro is designed to be executed on users side so yes-You need to design it so when users are opening your xlsm file then macro runs. It can run for example when “on open” trigger kicks in. 

now discussing paging solution may be possible but we would need to understand scenarios in detail. 

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

4 Replies
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

hi Kris,


Its simple - yes - nprinting does not execute macro during report generation. That macro is designed to be executed on users side so yes-You need to design it so when users are opening your xlsm file then macro runs. It can run for example when “on open” trigger kicks in. 

now discussing paging solution may be possible but we would need to understand scenarios in detail. 

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Ruggero_Piccoli
Support
Support

Hi,

VBA macros are supported only in Excel templates. Supported means that you can import an .xlsm file with VBA code or develop VBA code during the template editing. Then, if in the publish task you select .xlsm as output format, that VBA code will be copied in all generated reports but never executed for security reasons. 

You can follow @Lech_Miszkiewicz 's suggestion and trigger the macros execution on file opening or let the user to run them manually. 

Best Regards,

Ruggero



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
Andrea_Bertazzo
Support
Support

Hi,

You can consider some alternative solutions to Macros to  display some objects according to the filters. An option that you can apply in Excel reports is the object filter:

https://help.qlik.com/en-US/nprinting/May2021/Content/NPrinting/ReportsDevelopment/Static-dynamic-fi...

A more effective option is the conditional output. This can be applied only to PixelPerfect reports:

https://help.qlik.com/en-US/nprinting/May2021/Content/NPrinting/PixelPerfectReports/Manage-Condition...

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up ! 🙂
kdmarkee221
Contributor III
Contributor III
Author

Thanks everyone.  I'll continue to experiment with macro code by adding in some Open logic.  And the object filter idea only works partially...it won't show the object in the worksheet, but the worksheet still shows up and this will only confuse our clients.