<?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: How to set a variable to 0 inside macro in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889312#M657386</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All these answer works by them self, but not togheter with my script. The problem is that I don't know where to put it.&lt;/P&gt;&lt;P&gt;The requirement is that it should set the variable=0 when all loops and pdf/mail is ready, last thing before quit the application.&lt;/P&gt;&lt;P&gt;I have test and in some case the code stops because it get 0 in wrong place or doesent get 0 at all if I put it as a single Sub in the bottom. Any Idea, see script above.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 May 2015 10:49:50 GMT</pubDate>
    <dc:creator>stabben23</dc:creator>
    <dc:date>2015-05-20T10:49:50Z</dc:date>
    <item>
      <title>How to set a variable to 0 inside macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889307#M657379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I Run a qlikview file from a batchload where I send a variable=1. This is a trigger that start a reload of the application and also send pdf files. In the end of the macro I would like to set this variable to 0. Because my variable is a OnOpen trigger, and the application runs everytime I forgot to hold Ctrl + Shift down.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 14:04:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889307#M657379</guid>
      <dc:creator>stabben23</dc:creator>
      <dc:date>2015-05-19T14:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a variable to 0 inside macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889308#M657380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this one:&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #000000; font-family: 'Times New Roman'; font-size: medium;"&gt;&lt;CODE&gt;set v = ActiveDocument.Variables("Variable1")&lt;BR /&gt;v.SetContent "123",true&lt;/CODE&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Andrei&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 07:17:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889308#M657380</guid>
      <dc:creator>crusader_</dc:creator>
      <dc:date>2015-05-20T07:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a variable to 0 inside macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889309#M657382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can see that it works, but I dont know where to add it into the script, can you help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub&amp;nbsp; vecka&lt;/P&gt;&lt;P&gt;ActiveDocument.ClearAll True&lt;/P&gt;&lt;P&gt;SET x=ActiveDocument.GetVariable("vPdfVariable")&lt;BR /&gt;&amp;nbsp; if x.GetContent.String=x.GetContent.String then&lt;BR /&gt;&amp;nbsp; ActiveDocument.Reload&lt;BR /&gt;&amp;nbsp; ActiveDocument.GetApplication.WaitForIdle&lt;/P&gt;&lt;P&gt;Set Prods = ActiveDocument.Fields("SäljareNamn").GetPossibleValues&lt;/P&gt;&lt;P&gt;For i = 0 to Prods.count -1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveDocument.Fields("SäljareNamn").Select Prods.item(i).Text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DagRapport()&lt;/P&gt;&lt;P&gt;Next&lt;BR /&gt;ActiveDocument.ClearAll True&lt;BR /&gt;ActiveDocument.Save&lt;BR /&gt;&amp;nbsp; ActiveDocument.GetApplication.Quit&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp; End if&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Sub Dagrapport()&lt;BR /&gt; &lt;BR /&gt;SET x=ActiveDocument.GetVariable("vPdfVariable")&lt;BR /&gt;&amp;nbsp; if x.GetContent.String=x.GetContent.String then&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;set v=ActiveDocument.Fields("SäljareNamn").GetSelectedValues&lt;BR /&gt;set vmail=ActiveDocument.Fields("mail").GetPossibleValues&lt;/P&gt;&lt;P&gt;set vPrint=ActiveDocument.Fields("SäljareNamn").GetPossibleValues&lt;BR /&gt;End if &lt;BR /&gt; &lt;BR /&gt;IF(v.Count = 1 and vPrint.item(i).Text = v(i).Text) Then &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vReport = "RP0"&amp;amp; x.GetContent.String 'Set report&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vName = (v(i).Text) 'Name of output pdf&lt;/P&gt;&lt;P&gt;ActiveDocument.PrintReport(vReport), "Bullzip PDF Printer", false 'Printreport&lt;BR /&gt;printReportPDF = "C:\xxxx\pdftest\"&amp;amp;vName&amp;amp;"\" &amp;amp; vName &amp;amp; x.GetContent.String&amp;amp;".pdf" 'Setting outputname&lt;BR /&gt;MyPrintPDFWithBullZip(printReportPDF) 'Call pdf printer&lt;BR /&gt;ActiveDocument.GetApplication.Sleep 10000&lt;/P&gt;&lt;P&gt;Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. &lt;BR /&gt;Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). &lt;/P&gt;&lt;P&gt;Const cdoAnonymous = 0 'Do not authenticate&lt;BR /&gt;Const cdoBasic = 1 'basic (clear-text) authentication&lt;BR /&gt;Const cdoNTLM = 2 'NTLM&lt;BR /&gt;Set objMessage = CreateObject("CDO.Message") &lt;BR /&gt;objMessage.Subject = vName &amp;amp;" " &amp;amp; Date() &lt;BR /&gt;&lt;SPAN&gt;objMessage.From = """QlikViewserver"" &amp;lt;&lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:qlikview@xxx.xx"&gt;qlikview@xxx.xx&lt;/A&gt;&lt;SPAN&gt;&amp;gt;"&lt;/SPAN&gt;&lt;BR /&gt;objMessage.To= vmail.item(i).Text &lt;BR /&gt;objMessage.AddAttachment "C:\xxxx\pdftest\"&amp;amp;vName&amp;amp;"\" &amp;amp; vName &amp;amp; x.GetContent.String&amp;amp;".pdf"&lt;/P&gt;&lt;P&gt;'==This section provides the configuration information for the remote SMTP server.&lt;/P&gt;&lt;P&gt;objMessage.Configuration.Fields.Item _&lt;BR /&gt;&lt;SPAN&gt;("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://schemas.microsoft.com/cdo/configuration/sendusing" rel="nofollow"&gt;http://schemas.microsoft.com/cdo/configuration/sendusing&lt;/A&gt;&lt;SPAN&gt;") = 2 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;'Name or IP of Remote SMTP Server&lt;BR /&gt;objMessage.Configuration.Fields.Item _&lt;BR /&gt;&lt;SPAN&gt;("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://schemas.microsoft.com/cdo/configuration/smtpserver" rel="nofollow"&gt;http://schemas.microsoft.com/cdo/configuration/smtpserver&lt;/A&gt;&lt;SPAN&gt;") = "xxxxxxxxxxxx"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;'Type of authentication, NONE, Basic (Base64 encoded), NTLM&lt;BR /&gt;objMessage.Configuration.Fields.Item _&lt;BR /&gt;&lt;SPAN&gt;("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" rel="nofollow"&gt;http://schemas.microsoft.com/cdo/configuration/smtpauthenticate&lt;/A&gt;&lt;SPAN&gt;") = cdoBasic &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;'Your UserID on the SMTP server&lt;BR /&gt;objMessage.Configuration.Fields.Item _&lt;BR /&gt;&lt;SPAN&gt;("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://schemas.microsoft.com/cdo/configuration/sendusername" rel="nofollow"&gt;http://schemas.microsoft.com/cdo/configuration/sendusername&lt;/A&gt;&lt;SPAN&gt;") = "xxxxxxxxxx"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;'Your password on the SMTP server&lt;BR /&gt;objMessage.Configuration.Fields.Item _&lt;BR /&gt;&lt;SPAN&gt;("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://schemas.microsoft.com/cdo/configuration/sendpassword" rel="nofollow"&gt;http://schemas.microsoft.com/cdo/configuration/sendpassword&lt;/A&gt;&lt;SPAN&gt;") = xxxxxxxxxxx&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;'Server port (typically 25)&lt;BR /&gt;objMessage.Configuration.Fields.Item _&lt;BR /&gt;&lt;SPAN&gt;("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://schemas.microsoft.com/cdo/configuration/smtpserverport" rel="nofollow"&gt;http://schemas.microsoft.com/cdo/configuration/smtpserverport&lt;/A&gt;&lt;SPAN&gt;") = xxx &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;'Use SSL for the connection (False or True)&lt;BR /&gt;objMessage.Configuration.Fields.Item _&lt;BR /&gt;&lt;SPAN&gt;("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://schemas.microsoft.com/cdo/configuration/smtpusessl" rel="nofollow"&gt;http://schemas.microsoft.com/cdo/configuration/smtpusessl&lt;/A&gt;&lt;SPAN&gt;") = False&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)&lt;BR /&gt;objMessage.Configuration.Fields.Item _&lt;BR /&gt;&lt;SPAN&gt;("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" rel="nofollow"&gt;http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout&lt;/A&gt;&lt;SPAN&gt;") = xx&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;objMessage.Configuration.Fields.Update&lt;/P&gt;&lt;P&gt;'==End remote SMTP server configuration section==&lt;/P&gt;&lt;P&gt;objMessage.Send&lt;/P&gt;&lt;P&gt;Set objMessage = Nothing &lt;/P&gt;&lt;P&gt;end if&lt;BR /&gt;end sub&lt;/P&gt;&lt;P&gt;FUNCTION MyPrintPDFWithBullZip (pdfOutputFile)&lt;BR /&gt;set obj = CreateObject("Bullzip.PDFSettings")&lt;BR /&gt;obj.SetValue "Output" , pdfOutputFile&lt;BR /&gt;obj.SetValue "ConfirmOverwrite", "no"&lt;BR /&gt;obj.SetValue "ShowSaveAS", "never"&lt;BR /&gt;obj.SetValue "ShowSettings", "never"&lt;BR /&gt;obj.SetValue "ShowPDF", "no"&lt;BR /&gt;obj.SetValue "RememberLastFileName", "no"&lt;BR /&gt;obj.SetValue "RememberLastFolderName", "no"&lt;BR /&gt;obj.SetValue "ShowProgressFinished", "no"&lt;BR /&gt;obj.SetValue "ShowProgress", "no"&lt;BR /&gt;obj.WriteSettings True&lt;/P&gt;&lt;P&gt;Set WSHShell = CreateObject("WScript.Shell")&lt;/P&gt;&lt;P&gt;&amp;nbsp; WSHShell.RegWrite "HKCU\Software\QlikViewPDF\OutputFile", pdfOutputFile, "REG_SZ"&lt;BR /&gt;&amp;nbsp; WSHShell.RegWrite "HKCU\Software\QlikViewPDF\BypassSaveAs", "1", "REG_SZ"&lt;/P&gt;&lt;P&gt;Set WSHShell = nothing&lt;/P&gt;&lt;P&gt;End FUNCTION&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 09:05:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889309#M657382</guid>
      <dc:creator>stabben23</dc:creator>
      <dc:date>2015-05-20T09:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a variable to 0 inside macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889310#M657383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check below link for lot of such macro code snippets&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/docs/DOC-4870"&gt;Useful Qlikview Macros&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jagan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 09:11:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889310#M657383</guid>
      <dc:creator>jagan</dc:creator>
      <dc:date>2015-05-20T09:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a variable to 0 inside macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889311#M657385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi , &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this code, It will assign variable value as 0 in UI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub ChangeValue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveDocument.Variables("variable").SetContent "0", true&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &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;Let me know if your requirement is different. &lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;BKC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 09:55:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889311#M657385</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-20T09:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a variable to 0 inside macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889312#M657386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All these answer works by them self, but not togheter with my script. The problem is that I don't know where to put it.&lt;/P&gt;&lt;P&gt;The requirement is that it should set the variable=0 when all loops and pdf/mail is ready, last thing before quit the application.&lt;/P&gt;&lt;P&gt;I have test and in some case the code stops because it get 0 in wrong place or doesent get 0 at all if I put it as a single Sub in the bottom. Any Idea, see script above.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 10:49:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889312#M657386</guid>
      <dc:creator>stabben23</dc:creator>
      <dc:date>2015-05-20T10:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a variable to 0 inside macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889313#M657388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I Add ChangeValue() here to get it to work, thaks for putting me in the right direction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub&amp;nbsp; vecka&lt;/P&gt;&lt;P&gt;ActiveDocument.ClearAll True&lt;/P&gt;&lt;P&gt;SET x=ActiveDocument.GetVariable("vPdfVariable")&lt;BR /&gt;&amp;nbsp; if x.GetContent.String=x.GetContent.String then&lt;BR /&gt;&amp;nbsp; ActiveDocument.Reload&lt;BR /&gt;&amp;nbsp; ActiveDocument.GetApplication.WaitForIdle&lt;/P&gt;&lt;P&gt;Set Prods = ActiveDocument.Fields("SäljareNamn").GetPossibleValues&lt;/P&gt;&lt;P&gt;For i = 0 to Prods.count -1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveDocument.Fields("SäljareNamn").Select Prods.item(i).Text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DagRapport()&lt;/P&gt;&lt;P&gt;Next&lt;BR /&gt;ActiveDocument.ClearAll True&lt;BR /&gt;&lt;STRONG&gt;ChangeValue()&lt;/STRONG&gt;&lt;BR /&gt;ActiveDocument.Save&lt;BR /&gt;&amp;nbsp; ActiveDocument.GetApplication.Quit&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp; End if&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;End Sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 12:42:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889313#M657388</guid>
      <dc:creator>stabben23</dc:creator>
      <dc:date>2015-05-20T12:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a variable to 0 inside macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889314#M657389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;so now its working .. Good &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 12:49:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889314#M657389</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-20T12:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a variable to 0 inside macro</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889315#M657390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you want to set variable after all the work done just include &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt; ActiveDocument.Variables("variable").SetContent "0", true&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;before END SUB&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Thanks &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;BKC&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 05:37:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-set-a-variable-to-0-inside-macro/m-p/889315#M657390</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-21T05:37:39Z</dc:date>
    </item>
  </channel>
</rss>

