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

onactivatemacro - API substitute in QV9

Hi everyone.

Back when I developed a project under QV8.5, I used a small QVW application that would add or change the macro action on activating the sheets in several documents. The macro code used to look like this, and it worked perfectly:

for i = 0 to ActiveDocument.NoOfSheets - 1

set sheet = ActiveDocument.GetSheet(i)
set sp = sheet.GetProperties
sp.OnActivateMacro = "macro_name"
sheet.SetProperties sp

next

Dealing with a large amount of documents and sheets, this seemed to be, by far, the fastest solution.

In QV9, where macro triggers were changed to action triggers, the code got useless.

So far I only manged to get to a code that would change the already existing action under the sheet properties > triggers > on activate sheet actions. The problem is that, in many situations, there is no action defined, so nothing to change.

What I need is a code for VBModule that creates a new "on activate sheet" action and lets me set the type of the action (should be "Run Macro" in my case) and the name of the action (macro sub name, in my case). Oh, and most of all, it must be QV9 compatible :).

Thanks in advance,

Kos

1 Reply
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think you are out of luck. I've run up against the same problem with a macro that sets OnDeactivate and OnSelect events. In V9, I had to use the documented "_OBSOLETE" migration method, but as you experienced this let me reference the event that was set in V8 but not create a new action in V9.

I opened a support ticket to ask if Actions will have API access, and the reply was "No".

So setting events progamatically no longer seems possible in V9. Let me know if you find a way around it. I have a couple applications for it. I follow the rules and do it only at design time, never in Server environment. But it no longer seems possible.

-Rob