<?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 Run Macro on Post Reload Dependant on Variable Being Met in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145898#M24543</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Just one thing...&lt;BR /&gt;Can you use the variable like that??&lt;BR /&gt;Woluden't you use the following construct?&lt;/P&gt;&lt;P&gt;sub ExportReports&lt;BR /&gt;set v = ActiveDocument.Variables("vControl")&lt;BR /&gt;if v.GetContent.String &amp;lt;&amp;gt; "0" then&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Then I would do a&lt;BR /&gt;"ActiveDocument.GetApplication.WaitForIdle"&lt;BR /&gt;after the selection and before the export... You never know...&lt;/P&gt;&lt;P&gt;BR&lt;BR /&gt;Hans&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Jun 2009 04:30:46 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-06-05T04:30:46Z</dc:date>
    <item>
      <title>Run Macro on Post Reload Dependant on Variable Being Met</title>
      <link>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145894#M24539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm struggling with a basic macro to export tables as .xls on a set day.&lt;/P&gt;&lt;P&gt;The .qvw is automatically reloaded overnight, I want to be able to set a date in the future that when the file is reloaded on that date the .qvw will export several tables. I've got the macro to do the export working fine and can kick it off after the reload but getting it to &lt;STRONG&gt;only&lt;/STRONG&gt; do it on the day I need is tricky.&lt;/P&gt;&lt;P&gt;The macro I have so far is:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;Sub ExportReports&lt;/I&gt;&lt;/STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;if vControl &amp;lt;&amp;gt;0 then&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;ActiveDocument.ClearAll&lt;/I&gt;&lt;/STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;ActiveDocument.Fields("Plan").Select "X"&lt;/I&gt;&lt;/STRONG&gt;&lt;B&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;BR /&gt;&lt;STRONG&gt;set obj = ActiveDocument.GetSheetObject("TB01")&lt;/STRONG&gt;&lt;/I&gt;&lt;BR /&gt;&lt;STRONG&gt;obj.ExportBiff "P:\ReportX.xls"&lt;/STRONG&gt;&lt;/B&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;ActiveDocument.Fields("Plan").Select "Y"&lt;/I&gt;&lt;/STRONG&gt;&lt;B&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;BR /&gt;&lt;STRONG&gt;set obj = ActiveDocument.GetSheetObject("TB01")&lt;/STRONG&gt;&lt;/I&gt;&lt;BR /&gt;&lt;STRONG&gt;obj.ExportBiff "P:\ReportY.xls"&lt;/STRONG&gt;&lt;/B&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;ActiveDocument.Fields("Plan").Select "Z"&lt;/I&gt;&lt;/STRONG&gt;&lt;B&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;BR /&gt;&lt;STRONG&gt;set obj = ActiveDocument.GetSheetObject("TB01")&lt;/STRONG&gt;&lt;/I&gt;&lt;BR /&gt;&lt;STRONG&gt;obj.ExportBiff "P:\ReportZ.xls"&lt;/STRONG&gt;&lt;/B&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;ActiveDocument.ClearAll&lt;/I&gt;&lt;/STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;End if&lt;/I&gt;&lt;/STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;End Sub&lt;/I&gt;&lt;/STRONG&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Where "vControl" is a variable &lt;I style="mso-bidi-font-style: normal;"&gt;=&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;if&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;(&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;vToday&lt;/I&gt; &lt;I style="mso-bidi-font-style: normal;"&gt;=&lt;/I&gt; &lt;I style="mso-bidi-font-style: normal;"&gt;vReportDate&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;,&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;1&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;,&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;0&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal;"&gt;)&lt;/I&gt; with "vToday" being today's date and "vReportDate" being the desired report creation date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried various different methods but each either fails to run the macro at all or runs it regardless of the date???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any pointers gratefully received.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jun 2009 18:11:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145894#M24539</guid>
      <dc:creator />
      <dc:date>2009-06-04T18:11:42Z</dc:date>
    </item>
    <item>
      <title>Run Macro on Post Reload Dependant on Variable Being Met</title>
      <link>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145895#M24540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems to be working with below variable definitions -&lt;/P&gt;&lt;P&gt;vToday: =Today()&lt;/P&gt;&lt;P&gt;vReportDate: =MakeDate(2009,6,3)&lt;/P&gt;&lt;P&gt;vControl: =if(vToday = vReportDate,1,0)&lt;/P&gt;&lt;P&gt;Tested with a text object showing the value of vControl for different dates&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jun 2009 21:22:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145895#M24540</guid>
      <dc:creator />
      <dc:date>2009-06-04T21:22:15Z</dc:date>
    </item>
    <item>
      <title>Run Macro on Post Reload Dependant on Variable Being Met</title>
      <link>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145896#M24541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a useful tip:&lt;/P&gt;&lt;P&gt;Be very carefull about using the function Today(), because that will always have the values of the last time the file was opened. Use Today(1) to get the current date, regardless of everything else.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jun 2009 21:30:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145896#M24541</guid>
      <dc:creator />
      <dc:date>2009-06-04T21:30:56Z</dc:date>
    </item>
    <item>
      <title>Run Macro on Post Reload Dependant on Variable Being Met</title>
      <link>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145897#M24542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks for the responses.&lt;/P&gt;&lt;P&gt;It wasn't the variables I was having the problems with; I can control the 'vControl' variable as required, the issue has been getting the macro 'ExportReports' to "pay attention" to the variable and only run when vControl = 1.&lt;/P&gt;&lt;P&gt;However I've come up with a cowboy work around:&lt;/P&gt;&lt;P&gt;A Sub that's called post-reload 'presses' a button object which in turn calls the ExportReports functionality in a second Sub - the button is conditional on vToday being equal to vReportDate (ie vControl = 1). If the button isn't visible the Sub initiated post-reload can't press it therefore the 2nd Sub containnig the export functionality doesn't run.&lt;/P&gt;&lt;P&gt;As I said "Cowboy"...&lt;/P&gt;&lt;P&gt;There must be a better/neater way to do it than this??&lt;/P&gt;&lt;P&gt;Once again; many thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Jun 2009 22:03:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145897#M24542</guid>
      <dc:creator />
      <dc:date>2009-06-04T22:03:00Z</dc:date>
    </item>
    <item>
      <title>Run Macro on Post Reload Dependant on Variable Being Met</title>
      <link>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145898#M24543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Just one thing...&lt;BR /&gt;Can you use the variable like that??&lt;BR /&gt;Woluden't you use the following construct?&lt;/P&gt;&lt;P&gt;sub ExportReports&lt;BR /&gt;set v = ActiveDocument.Variables("vControl")&lt;BR /&gt;if v.GetContent.String &amp;lt;&amp;gt; "0" then&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Then I would do a&lt;BR /&gt;"ActiveDocument.GetApplication.WaitForIdle"&lt;BR /&gt;after the selection and before the export... You never know...&lt;/P&gt;&lt;P&gt;BR&lt;BR /&gt;Hans&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2009 04:30:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Run-Macro-on-Post-Reload-Dependant-on-Variable-Being-Met/m-p/145898#M24543</guid>
      <dc:creator />
      <dc:date>2009-06-05T04:30:46Z</dc:date>
    </item>
  </channel>
</rss>

