Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Macro - create button to set variable

Hi,

Just a quick question and I hope someone can help.

I am trying to make a macro which creates a new button and sets the action of this button to update a variable setting.

So far I have got the below which creates the button, names it and inserts the name of the variable to be updated but I cant seem to work out form the API what i should do next to insert the new variable value?

set newbutton = ActiveDocument.ActiveSheet.CreateButton

          set prop = newbutton.GetProperties

          prop.Text.v = "Remove"

 

          set ButtonActions = prop.ActionItems

          ButtonActions.Add

          ButtonActions.Item(0).Type=31 'Macro Varible set

          set ActionParam=ButtonActions.Item(0).Parameters

          ActionParam.Add

          ActionParam.Item(0).v="Test"

I am not sure what should come next...something like?

          ActionParam.Item(0).Data="Test2"

Thanks for your help!

Tags (2)
1 Solution

Accepted Solutions

Re: Macro - create button to set variable

You need to parameters for the set variable action

Sub CreateButton

set newbutton = ActiveDocument.ActiveSheet.CreateButton

          set prop = newbutton.GetProperties

          prop.Text.v = "Remove"

         set ButtonActions = prop.ActionItems

           ButtonActions.Add

           ButtonActions.Item(0).Type=31 'Macro Varible set

           set ActionParam=ButtonActions.Item(0).Parameters

           ActionParam.Add

           ActionParam.Item(0).v="v_Test"

          ActionParam.Add

           ActionParam.Item(1).v="Test"

          newbutton.SetProperties prop

   

end sub


talk is cheap, supply exceeds demand
2 Replies

Re: Macro - create button to set variable

You need to parameters for the set variable action

Sub CreateButton

set newbutton = ActiveDocument.ActiveSheet.CreateButton

          set prop = newbutton.GetProperties

          prop.Text.v = "Remove"

         set ButtonActions = prop.ActionItems

           ButtonActions.Add

           ButtonActions.Item(0).Type=31 'Macro Varible set

           set ActionParam=ButtonActions.Item(0).Parameters

           ActionParam.Add

           ActionParam.Item(0).v="v_Test"

          ActionParam.Add

           ActionParam.Item(1).v="Test"

          newbutton.SetProperties prop

   

end sub


talk is cheap, supply exceeds demand
Not applicable

Re: Macro - create button to set variable

Thats brilliant thank you so much!

Community Browser