<?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 Re:Replacing Table Box from Macro (VBS) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Replacing-Table-Box-from-Macro-VBS/m-p/157384#M32890</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank's a lot John!!!&lt;/P&gt;&lt;P&gt;I could have solved my problem.&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;Pol&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 16 Aug 2009 01:21:49 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-08-16T01:21:49Z</dc:date>
    <item>
      <title>Replacing Table Box from Macro (VBS)</title>
      <link>https://community.qlik.com/t5/QlikView/Replacing-Table-Box-from-Macro-VBS/m-p/157381#M32887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;I am using this macro to create a table box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;sub SeleccionarCampos&lt;BR /&gt;set val=ActiveDocument.Fields("CamposSelecPresup").GetPossibleValues&lt;BR /&gt;&lt;BR /&gt;set TB = ActiveDocument.Sheets("Hoja8").CreateTableBox&lt;BR /&gt;&lt;BR /&gt;for i=0 to val.Count-1&lt;BR /&gt; 'msgbox(val.Item(i).Text)&lt;BR /&gt; TB.AddField val.Item(i).Text&lt;BR /&gt;next&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;end sub&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;BR /&gt;Could be possible to give it always the same ID in order to replace the table box that have that ID?&lt;/P&gt;&lt;P&gt;Thank's!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2009 23:03:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Replacing-Table-Box-from-Macro-VBS/m-p/157381#M32887</guid>
      <dc:creator />
      <dc:date>2009-08-13T23:03:12Z</dc:date>
    </item>
    <item>
      <title>Replacing Table Box from Macro (VBS)</title>
      <link>https://community.qlik.com/t5/QlikView/Replacing-Table-Box-from-Macro-VBS/m-p/157382#M32888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;some idea?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2009 16:59:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Replacing-Table-Box-from-Macro-VBS/m-p/157382#M32888</guid>
      <dc:creator />
      <dc:date>2009-08-14T16:59:38Z</dc:date>
    </item>
    <item>
      <title>Re:Replacing Table Box from Macro (VBS)</title>
      <link>https://community.qlik.com/t5/QlikView/Replacing-Table-Box-from-Macro-VBS/m-p/157383#M32889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could replace the contents of the table box instead of adding a new one, and only display the table box if there is at least one value possible in "CamposSelecPresup". Attached is an example. See the "TABLE BOX ONLY?" section of the macro. Warning: I believe QlikView only keeps a single copy of each object, so if multiple users are changing it at the same time, I don't guarantee they'll get what they wanted. You may be better off just removing the old object and adding a new one, as I gather you do already.&lt;/P&gt;&lt;P&gt;Edit: Well, it's not letting me attach the application, so here's the macro.&lt;/P&gt;&lt;P&gt;sub rebuild()&lt;BR /&gt; set AllowCalculation = ActiveDocument.Variables("AllowCalculation")&lt;BR /&gt; AllowCalculation.SetContent 0, true 'Display the "Please wait..." text object&lt;BR /&gt; ActiveDocument.GetApplication.WaitForIdle 'wait for QlikView to finish before modifying report&lt;BR /&gt; set selectedExpressions = ActiveDocument.getField("Expressions").getSelectedValues&lt;BR /&gt; set selectedDimensions = ActiveDocument.getField("Dimensions").getSelectedValues&lt;BR /&gt; selectedExpressionMax = selectedExpressions.Count - 1&lt;BR /&gt; selectedDimensionMax = selectedDimensions.Count - 1&lt;BR /&gt; if selectedExpressionMax + selectedDimensionMax &amp;gt; -2 then 'bypass if nothing is selected&lt;BR /&gt;'--------------------------- TABLE BOX ONLY? ---------------------------------------------------&lt;BR /&gt; if selectedExpressionMax = -1 then&lt;BR /&gt; set table = ActiveDocument.getSheetObject("TB01")&lt;BR /&gt; tableDimensionMax = table.GetColumnCount - 1&lt;BR /&gt; for i = tableDimensionMax to 0 step -1 'remove existing dimensions&lt;BR /&gt; table.removeField i&lt;BR /&gt; next&lt;BR /&gt; for j = 0 to selectedDimensionMax 'add selected dimensions&lt;BR /&gt; table.addField selectedDimensions.Item(j).Text&lt;BR /&gt; next&lt;BR /&gt; else&lt;BR /&gt;'--------------------------- EXPRESSIONS ------------------------------------------------------&lt;BR /&gt; set chart = ActiveDocument.getSheetObject("CH01")&lt;BR /&gt; set chartProperties = chart.GetProperties&lt;BR /&gt; set chartExpressions = chartProperties.Expressions&lt;BR /&gt; chartExpressionMax = chartExpressions.Count - 1&lt;BR /&gt; dim selectedExpression(100) 'runs slightly faster if first set up a simple array&lt;BR /&gt; for j = 0 to selectedExpressionMax&lt;BR /&gt; selectedExpression(j) = selectedExpressions.Item(j).Text&lt;BR /&gt; next&lt;BR /&gt; for i = 0 to chartExpressionMax 'for every possible expression defined to the chart&lt;BR /&gt; e = chartExpressions.Item(i).Item(0).Data&lt;BR /&gt; chartExpression = e.ExpressionVisual.Label.v&lt;BR /&gt; expression = e.ExpressionData&lt;BR /&gt; expression.Enable = false 'disable the expression&lt;BR /&gt; for j = 0 to selectedExpressionMax 'check all selected expressions&lt;BR /&gt; if selectedExpression(j) = chartExpression then 'if user selected the expression&lt;BR /&gt; expression.Enable = true 'enable it&lt;BR /&gt; j = 9999 'and exit the inner loop&lt;BR /&gt; end if&lt;BR /&gt; next&lt;BR /&gt; next&lt;BR /&gt; ActiveDocument.GetApplication.WaitForIdle&lt;BR /&gt; chartProperties.GraphLayout.WindowTitle.v = "Custom Report"&lt;BR /&gt; chart.SetProperties chartProperties&lt;BR /&gt;'--------------------------- DIMENSIONS --------------------------------------------------------&lt;BR /&gt; chartDimensionMax = chart.GetColumnCount - 1&lt;BR /&gt; for i = chartDimensionMax to 0 step -1 'remove existing dimensions&lt;BR /&gt; chart.removeDimension i&lt;BR /&gt; next&lt;BR /&gt; for j = 0 to selectedDimensionMax 'add selected dimensions&lt;BR /&gt; chart.addDimension selectedDimensions.Item(j).Text&lt;BR /&gt; next&lt;BR /&gt; end if&lt;BR /&gt; end if&lt;BR /&gt; AllowCalculation.SetContent 1, true 'allow dynamic report to recalculate&lt;BR /&gt;end sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Aug 2009 00:51:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Replacing-Table-Box-from-Macro-VBS/m-p/157383#M32889</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2009-08-15T00:51:13Z</dc:date>
    </item>
    <item>
      <title>Re:Replacing Table Box from Macro (VBS)</title>
      <link>https://community.qlik.com/t5/QlikView/Replacing-Table-Box-from-Macro-VBS/m-p/157384#M32890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank's a lot John!!!&lt;/P&gt;&lt;P&gt;I could have solved my problem.&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;Pol&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Aug 2009 01:21:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Replacing-Table-Box-from-Macro-VBS/m-p/157384#M32890</guid>
      <dc:creator />
      <dc:date>2009-08-16T01:21:49Z</dc:date>
    </item>
  </channel>
</rss>

