<?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 &amp;quot;Clear Field&amp;quot; actions to a Text Object in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-to-add-quot-Clear-Field-quot-actions-to-a-Text-Object/m-p/1353752#M613935</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Hi all -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm attempting to write a macro that will add a "Clear Field" action to a specified text object for every field that exists within a particular table in my qvw (the Calendar table in the below example).&amp;nbsp; The below code works in the following scenarios:&lt;/P&gt;&lt;P&gt;1. I create a new text object and run the macro.&amp;nbsp; The initial run of the macro works, however subsequent runs add only the first and last field in my table.&lt;/P&gt;&lt;P&gt;2. I add a message box to the code below to display k for each value of the index&lt;/P&gt;&lt;P&gt;3. I run this macro via an external program that opens the QVW, runs the macro, and then closes the QVW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have any thoughts on additional things to try?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub ButtonActionsFields&lt;/P&gt;&lt;P&gt;set flds=ActiveDocument.GetFieldDescriptions&lt;/P&gt;&lt;P&gt;fldcount=0&lt;/P&gt;&lt;P&gt;for i=0 to flds.count-1&lt;/P&gt;&lt;P&gt; set fld=flds.item(i)&lt;/P&gt;&lt;P&gt; if not fld.IsSystem then&lt;/P&gt;&lt;P&gt;&amp;nbsp; fldTableCount=ubound(fld.SrcTables)+1&lt;/P&gt;&lt;P&gt;&amp;nbsp; tables=fld.SrcTables&lt;/P&gt;&lt;P&gt;&amp;nbsp; fldTables=""&lt;/P&gt;&lt;P&gt;&amp;nbsp; for j=lbound(tables) to ubound(tables)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; fldTables=fldTables &amp;amp; tables(j) &amp;amp; ";"&lt;/P&gt;&lt;P&gt;&amp;nbsp; next&lt;/P&gt;&lt;P&gt; end if&lt;/P&gt;&lt;P&gt; if instr(fldtables,"Calendar") then&lt;/P&gt;&lt;P&gt;&amp;nbsp; fldcount=fldcount+1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'k=fldcount-1&lt;/P&gt;&lt;P&gt;&amp;nbsp; call AddClearFieldAction2(fld.name)&lt;/P&gt;&lt;P&gt; end if&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub AddClearFieldAction2(field)&lt;/P&gt;&lt;P&gt;&amp;nbsp; set Button1= ActiveDocument.GetSheetObject("TX1001")&lt;/P&gt;&lt;P&gt;&amp;nbsp; set prop1 = Button1.GetProperties&lt;/P&gt;&lt;P&gt;&amp;nbsp; set actions1 = prop1.Layout.ActionItems&lt;/P&gt;&lt;P&gt;&amp;nbsp; actions1.Add&lt;/P&gt;&lt;P&gt;&amp;nbsp; k = actions1.count - 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'msgbox(k)&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'ActiveDocument.GetApplication.Sleep 2000&lt;/P&gt;&lt;P&gt;&amp;nbsp; actions1.Item(k).Type = 36&lt;/P&gt;&lt;P&gt;&amp;nbsp; actions1.Item(k).Parameters.Add&lt;/P&gt;&lt;P&gt;&amp;nbsp; actions1.Item(k).Parameters.Item(0).v = "[" &amp;amp; field &amp;amp; "]"&lt;/P&gt;&lt;P&gt;&amp;nbsp; Button1.SetProperties prop1&lt;/P&gt;&lt;P&gt;&amp;nbsp; set Button1 = nothing&lt;/P&gt;&lt;P&gt;&amp;nbsp; set prop1 = nothing&lt;/P&gt;&lt;P&gt;&amp;nbsp; set actions1 = nothing&lt;/P&gt;&lt;P&gt;&amp;nbsp; set k = nothing&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Jul 2017 16:17:08 GMT</pubDate>
    <dc:creator />
    <dc:date>2017-07-21T16:17:08Z</dc:date>
    <item>
      <title>Macro to add "Clear Field" actions to a Text Object</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-add-quot-Clear-Field-quot-actions-to-a-Text-Object/m-p/1353752#M613935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Hi all -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm attempting to write a macro that will add a "Clear Field" action to a specified text object for every field that exists within a particular table in my qvw (the Calendar table in the below example).&amp;nbsp; The below code works in the following scenarios:&lt;/P&gt;&lt;P&gt;1. I create a new text object and run the macro.&amp;nbsp; The initial run of the macro works, however subsequent runs add only the first and last field in my table.&lt;/P&gt;&lt;P&gt;2. I add a message box to the code below to display k for each value of the index&lt;/P&gt;&lt;P&gt;3. I run this macro via an external program that opens the QVW, runs the macro, and then closes the QVW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have any thoughts on additional things to try?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub ButtonActionsFields&lt;/P&gt;&lt;P&gt;set flds=ActiveDocument.GetFieldDescriptions&lt;/P&gt;&lt;P&gt;fldcount=0&lt;/P&gt;&lt;P&gt;for i=0 to flds.count-1&lt;/P&gt;&lt;P&gt; set fld=flds.item(i)&lt;/P&gt;&lt;P&gt; if not fld.IsSystem then&lt;/P&gt;&lt;P&gt;&amp;nbsp; fldTableCount=ubound(fld.SrcTables)+1&lt;/P&gt;&lt;P&gt;&amp;nbsp; tables=fld.SrcTables&lt;/P&gt;&lt;P&gt;&amp;nbsp; fldTables=""&lt;/P&gt;&lt;P&gt;&amp;nbsp; for j=lbound(tables) to ubound(tables)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; fldTables=fldTables &amp;amp; tables(j) &amp;amp; ";"&lt;/P&gt;&lt;P&gt;&amp;nbsp; next&lt;/P&gt;&lt;P&gt; end if&lt;/P&gt;&lt;P&gt; if instr(fldtables,"Calendar") then&lt;/P&gt;&lt;P&gt;&amp;nbsp; fldcount=fldcount+1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'k=fldcount-1&lt;/P&gt;&lt;P&gt;&amp;nbsp; call AddClearFieldAction2(fld.name)&lt;/P&gt;&lt;P&gt; end if&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub AddClearFieldAction2(field)&lt;/P&gt;&lt;P&gt;&amp;nbsp; set Button1= ActiveDocument.GetSheetObject("TX1001")&lt;/P&gt;&lt;P&gt;&amp;nbsp; set prop1 = Button1.GetProperties&lt;/P&gt;&lt;P&gt;&amp;nbsp; set actions1 = prop1.Layout.ActionItems&lt;/P&gt;&lt;P&gt;&amp;nbsp; actions1.Add&lt;/P&gt;&lt;P&gt;&amp;nbsp; k = actions1.count - 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'msgbox(k)&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'ActiveDocument.GetApplication.Sleep 2000&lt;/P&gt;&lt;P&gt;&amp;nbsp; actions1.Item(k).Type = 36&lt;/P&gt;&lt;P&gt;&amp;nbsp; actions1.Item(k).Parameters.Add&lt;/P&gt;&lt;P&gt;&amp;nbsp; actions1.Item(k).Parameters.Item(0).v = "[" &amp;amp; field &amp;amp; "]"&lt;/P&gt;&lt;P&gt;&amp;nbsp; Button1.SetProperties prop1&lt;/P&gt;&lt;P&gt;&amp;nbsp; set Button1 = nothing&lt;/P&gt;&lt;P&gt;&amp;nbsp; set prop1 = nothing&lt;/P&gt;&lt;P&gt;&amp;nbsp; set actions1 = nothing&lt;/P&gt;&lt;P&gt;&amp;nbsp; set k = nothing&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2017 16:17:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-add-quot-Clear-Field-quot-actions-to-a-Text-Object/m-p/1353752#M613935</guid>
      <dc:creator />
      <dc:date>2017-07-21T16:17:08Z</dc:date>
    </item>
  </channel>
</rss>

