Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I was wondering if it is possible to call a macro which is sitting within a qvw document from an external vbs file. The idea is, I have a macro in multiple dashboards with different implementation but same name. So what I want to do is call this macro from the vbs file based on other conditions I have specified in the vbs file.
Thanks for your ideas
Sorry, I do not understand what you are trying to achieve ...
Could you give us a more detailed example?
Best regards
Stefan
U have not explained the scenario clearly .But u can exceute a macro from a VBS file for Example u can open a qlikview file from VBS and in the open u can call one macro and then u can call ur second macro .If u dont want to call the macro on open tell me when u want to call the macro
Thank you all for your replies.
The problem is solved now but I would describe the scenario.
I have a macro that has the same name across all the dashboards I have which is again connected to a bookmark in each of the dashboards but implemented in each case differently. For example, the macro could be called "Update Bookmark" in all the dashboards but the implementation is different in each of the dashboards. So I wanted to call this macro from my external vbs file. What I did now is, I opened the qvw files, created a temp button, assigned this button to the "Update Bookmark" macro, and finally using the press property I could get it run without triggering the macro on open or some other method. At the end, before I close the qvw file, I will remove/drop the button and save the file. This is exactly what I wanted to achieve. Of course there are other tasks related to this but are irrelevant here.
I thought about triggering the macros on open but the they are too complex and not really effective for what we are trying to get.
Hi, one question.. when you say "and in the open u can call one macro", do you mean on the open for the qlikview document (like on the on open action), or on the open doc on the VBS code you can call the macro? and if so, how can this be accomplished? 🙂 thanks!
I think qliksus meant the document that is open. what i did in my case is:
...
'Create a button to refresh bookmarks and run the macro XYZ
set RunMacro = ActiveDocument.ActiveSheet.CreateButton
button_id = right(RunMacro.GetObjectId, 4)
set prop = RunMacro.GetProperties
prop.Type = 2
prop.Macro = "XYZ"
RunMacro.SetProperties prop
-----other conditions omitted here for simplicity
RunMacro.Press
----other conditions omitted here for simplicity
call deleteButton
'======================The following sub routine is also in your vbs file not in qvw file
sub deleteButton
set s=ActiveDocument.ActiveSheet
buttons=s.GetButtons
for j=lbound(buttons) to ubound(buttons)
if right(buttons(j).GetObjectId,4) = button_id then
buttons(j).Close
exit for
end if
next
sub function
what i did is just, i created a button in the opened qv document, assigned it a macro from the qv document, run the macro by pressing the button, and finally called the delete button sub routine to delete the button. The only thing you need to know is just to know the name of the macro you want to run.
Hope this helps
The prop.Macro and prop.Type = 2 are obsolete in QlikView 9. Any one knows what member functions can be used to obtain the same behavior from a vbs script?
Thanks,
P
Have a look at Action items in the API. Action replaces macros.
cheers