Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In QlikView 9, I need to write a macro which take an existing button within a document and change the URL which the button launches based on selections within the sheet. I know how to find the selections and build the URL, but what I cannot determine is what properties to set on the button.
set btn = ActiveDoc.GetSheetObject("BU23")
set prop = btn.GetProperties
--- In here, I need to set the properties for the URL to launch when the button is clicked
btn.SetProperties prop
I've checked through the forums and have not found an example of this, and the API reference refers to a type if IArrayOfActionItems but that type is not defined in the API qvw.
Thanks!
You are correct, that definition is missing in the API Guide.
A workaround I can suggest. Have your button call a sub where you can open IE with the manipulated URL. Something like this should work:
strLink= "http://www.yahoo.com"
Set objIExplorer = CreateObject("internetexplorer.application")
objIExplorer.visible = True
objIExplorer.navigate strLink
Set objIExplorer = Nothing
I should add that I need this to work when used from the QlikView server. Launching an application won't work, as it runs on the server.
You sure this doesn't work on the server?
Can you try putting just someple line in sub and test it out another option, which works in "web" environment usually. Just call:
window.open http://www.google.com
Sorry, don;t have access to a server right now.
Instead of messing with properties, define the button launch action as a variable and then manipulate the variable contents.
-Rob
Rob Wunderlich wrote:
Instead of messing with properties, define the button launch action as a variable and then manipulate the variable contents.
That's actually the first thing I thought of, but it doesn't seem to work. It's possible I'm doing something wrong.
Can you provide an example of setting the target of a launch action as a variable? I've gotten the variable set via the macro, but I cannot get the button to then launch the location specified by the variable.
-Kevin
Rakesh wrote:
You sure this doesn't work on the server?
Can you try putting just someple line in sub and test it out another option, which works in "web" environment usually. Just call:
window.open http://www.google.com
Sorry, don;t have access to a server right now. <div></div>
I believe window.open is for VB, not VB Script, but I will confirm that. I did this approach, which did not work on the server:
set app = ActiveDocument.Getapplication
app.Launch baseURL & "?" & params, ""
-Kevin
troj wrote:Can you provide an example of setting the target of a launch action as a variable? I've gotten the variable set via the macro, but I cannot get the button
Kevin,
Attached is an example of deriving the launch URL from selections without using a macro. Two methods are shown, build the URL in an Expression and building in a Variable. Hope this is what you were looking for.
-Rob
I've continued to play with this, in hopes of finding a solution. One thing of note is that I was originally trying this via the Ajax Client, which is something I'd still like to get working.
When I switch to the IE Plugin, I can use the following VB Script within a macro, and have it work. More than likely, this is because with IE, VB Script can run within the browser.
if (params = "") then
msgbox "No selections"
else
dim app
set app = ActiveDocument.Getapplication
app.Launch baseURL & "?" & params, ""
end if
I'd still like a method which works via Ajax, where the macro directly launches the page, or where I can change the launch URL for a button via a macro, or change a variable and have the button launch the contents of the variable.
-Kevin
Rob Wunderlich wrote:
Attached is an example of deriving the launch URL from selections without using a macro. Two methods are shown, build the URL in an Expression and building in a Variable. Hope this is what you were looking for. <div></div>
Thanks, Rob -- that showed me where I went wrong! I was trying
=$(variable)
instead of
=variable
as the URL.
It's the little things....
I'll give that a shot with the Ajax client, and see if it works.
-Kevin