<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Macro to add selection in Listbox in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-to-add-selection-in-Listbox/m-p/173737#M42816</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;My listbox should always have at least the first entry and another one selected. I have written a macro but it is not really doing anything (but it gets triggered). Found it also a bit difficult to find information how to manipulate qlik objects :-), the API Guide does not contain examples.&lt;/P&gt;&lt;P&gt;Sub include_first()&lt;BR /&gt;&lt;BR /&gt; ' always include first element in selection&lt;BR /&gt;&lt;BR /&gt; Set oLB_Cat = ActiveDocument.GetSheetObject("CAT")&lt;BR /&gt; Set oCell = oLB_Cat.GetCell(1,0)&lt;BR /&gt; oCell.State = 5&lt;BR /&gt; msgbox("Cell.State: " &amp;amp; oCell.State)&lt;BR /&gt;&lt;BR /&gt; ' if first element only is selected, select second too&lt;BR /&gt;&lt;BR /&gt; If oLB_Cat.GetRowCount = 1 Then&lt;BR /&gt; Set oCell = oLB_Cat.GetCell(2,0)&lt;BR /&gt; oCell.State = 5&lt;BR /&gt; End If&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;Thanks for your help, Juerg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Sep 2009 20:50:41 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-09-02T20:50:41Z</dc:date>
    <item>
      <title>Macro to add selection in Listbox</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-add-selection-in-Listbox/m-p/173737#M42816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;My listbox should always have at least the first entry and another one selected. I have written a macro but it is not really doing anything (but it gets triggered). Found it also a bit difficult to find information how to manipulate qlik objects :-), the API Guide does not contain examples.&lt;/P&gt;&lt;P&gt;Sub include_first()&lt;BR /&gt;&lt;BR /&gt; ' always include first element in selection&lt;BR /&gt;&lt;BR /&gt; Set oLB_Cat = ActiveDocument.GetSheetObject("CAT")&lt;BR /&gt; Set oCell = oLB_Cat.GetCell(1,0)&lt;BR /&gt; oCell.State = 5&lt;BR /&gt; msgbox("Cell.State: " &amp;amp; oCell.State)&lt;BR /&gt;&lt;BR /&gt; ' if first element only is selected, select second too&lt;BR /&gt;&lt;BR /&gt; If oLB_Cat.GetRowCount = 1 Then&lt;BR /&gt; Set oCell = oLB_Cat.GetCell(2,0)&lt;BR /&gt; oCell.State = 5&lt;BR /&gt; End If&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;Thanks for your help, Juerg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Sep 2009 20:50:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-add-selection-in-Listbox/m-p/173737#M42816</guid>
      <dc:creator />
      <dc:date>2009-09-02T20:50:41Z</dc:date>
    </item>
    <item>
      <title>Macro to add selection in Listbox</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-add-selection-in-Listbox/m-p/173738#M42817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I hope I understand what you're going for.&lt;/P&gt;&lt;P&gt;I set up a dummy app and gave it one field. I then set up a Trigger to fire on any Selection in that field. The macro will select the first value if it is not already selected, while keeping any other selections. Also, if the only thing selected if the first value, it also selects the second value. Here's the Sub:&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;Sub SelectFirst&lt;BR /&gt; set sel = ActiveDocument.Fields("Selections")&lt;BR /&gt;&lt;BR /&gt; Set oLB_Cat = ActiveDocument.GetSheetObject("LB01")&lt;BR /&gt; Set oCell = oLB_Cat.GetCell(0,0)&lt;BR /&gt; Set oCell2 = oLB_Cat.GetCell(1,0)&lt;BR /&gt;&lt;BR /&gt; selected = ActiveDocument.Variables("vSelected").GetContent.String&lt;BR /&gt;&lt;BR /&gt; ' To keep current selections&lt;BR /&gt; ' and select first&lt;BR /&gt; If Not InStr(selected, oCell.Text) Then&lt;BR /&gt; sel.ToggleSelect oCell.Text&lt;BR /&gt; End If&lt;BR /&gt;&lt;BR /&gt; ' Select first only&lt;BR /&gt; ' sel.Select oCell.Text&lt;BR /&gt; If sel.GetSelectedValues.Count = 1 Then&lt;BR /&gt; sel.ToggleSelect oCell2.Text&lt;BR /&gt; End If&lt;BR /&gt;End Sub&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I've also attached the sample app.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Sep 2009 21:13:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-add-selection-in-Listbox/m-p/173738#M42817</guid>
      <dc:creator />
      <dc:date>2009-09-02T21:13:50Z</dc:date>
    </item>
  </channel>
</rss>

