<?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 keeps running after closing document in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-keeps-running-after-closing-document/m-p/1432414#M430708</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Forum,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to upload the content of chart CH01 (65000 records in size) to a SQL database.&lt;/P&gt;&lt;P&gt;I use the macro below for that task.&lt;/P&gt;&lt;P&gt;The macro works fine. However, when the macro reaches the end, the qlikview program wont close. In the lower left corner of QlikView there is a message: "Macro running".&lt;/P&gt;&lt;P&gt;The document is however closed but the application is not.&lt;/P&gt;&lt;P&gt;Another strange thing to note here is that the application will close if i limit the no of records in the loop to 100. (instead of 65000)&lt;/P&gt;&lt;P&gt;This annoying freeze/hang of the macro prevents my intention of planning the document into task planner. Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub upload&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Const adOpenStatic = 3&lt;/P&gt;&lt;P&gt;Const adLockOptimistic = 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Establish a connection&lt;/P&gt;&lt;P&gt;Set objConnection = CreateObject("ADODB.Connection")&lt;/P&gt;&lt;P&gt;objConnection.open "PROVIDER=SQLOLEDB;DATA SOURCE=xxxxxx;UID=xxxxxx;PWD=xxxxxx;DATABASE=xxxxxx "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set objRecordSet = CreateObject("ADODB.Recordset")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'' First delete all records from the table.&lt;/P&gt;&lt;P&gt;objRecordSet.Open "DELETE FROM wm_customers",objConnection, adOpenStatic, adLockOptimistic&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;set TableObject = ActiveDocument.GetSheetObject( "CH01" )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For RowIter = 1 to TableObject.GetRowCount-1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set wmcustomer_no = TableObject.GetCell(RowIter,0)&lt;/P&gt;&lt;P&gt;set wmcustomer_name = TableObject.GetCell(RowIter,1)&lt;/P&gt;&lt;P&gt;set wmcustomer_address = TableObject.GetCell(RowIter,2) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set wmcustomer_place = TableObject.GetCell(RowIter,3)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set wmcustomer_participantid = TableObject.GetCell(RowIter,4)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set wmcustomer_id = TableObject.GetCell(RowIter,5) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Set SQL&lt;/P&gt;&lt;P&gt;objRecordSet.Open _&lt;/P&gt;&lt;P&gt;&amp;nbsp; "INSERT INTO wm_customers " &amp;amp; _&lt;/P&gt;&lt;P&gt;&amp;nbsp; "(wmcustomer_no,wmcustomer_name,wmcustomer_address,wmcustomer_place,wmcustomer_participantid,wmcustomer_id ) " &amp;amp; _&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "VALUES ('"&amp;amp;wmcustomer_no.text&amp;amp;"', '"&amp;amp;wmcustomer_name.text&amp;amp;"', '"&amp;amp;wmcustomer_address.text&amp;amp;"', '"&amp;amp;wmcustomer_place.text&amp;amp;"', '"&amp;amp;wmcustomer_participantid.text&amp;amp;"', '"&amp;amp;wmcustomer_id.text&amp;amp;"')", _&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objConnection, adOpenStatic, _&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; adLockOptimistic&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set objRecordSet = Nothing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;objConnection.Close&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set objConnection = Nothing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Application.Quit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ActiveDocument.GetApplication.Quit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Nov 2017 01:45:29 GMT</pubDate>
    <dc:creator>tabletuner</dc:creator>
    <dc:date>2017-11-08T01:45:29Z</dc:date>
    <item>
      <title>Macro keeps running after closing document</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-keeps-running-after-closing-document/m-p/1432414#M430708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Forum,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to upload the content of chart CH01 (65000 records in size) to a SQL database.&lt;/P&gt;&lt;P&gt;I use the macro below for that task.&lt;/P&gt;&lt;P&gt;The macro works fine. However, when the macro reaches the end, the qlikview program wont close. In the lower left corner of QlikView there is a message: "Macro running".&lt;/P&gt;&lt;P&gt;The document is however closed but the application is not.&lt;/P&gt;&lt;P&gt;Another strange thing to note here is that the application will close if i limit the no of records in the loop to 100. (instead of 65000)&lt;/P&gt;&lt;P&gt;This annoying freeze/hang of the macro prevents my intention of planning the document into task planner. Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub upload&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Const adOpenStatic = 3&lt;/P&gt;&lt;P&gt;Const adLockOptimistic = 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Establish a connection&lt;/P&gt;&lt;P&gt;Set objConnection = CreateObject("ADODB.Connection")&lt;/P&gt;&lt;P&gt;objConnection.open "PROVIDER=SQLOLEDB;DATA SOURCE=xxxxxx;UID=xxxxxx;PWD=xxxxxx;DATABASE=xxxxxx "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set objRecordSet = CreateObject("ADODB.Recordset")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'' First delete all records from the table.&lt;/P&gt;&lt;P&gt;objRecordSet.Open "DELETE FROM wm_customers",objConnection, adOpenStatic, adLockOptimistic&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;set TableObject = ActiveDocument.GetSheetObject( "CH01" )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For RowIter = 1 to TableObject.GetRowCount-1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set wmcustomer_no = TableObject.GetCell(RowIter,0)&lt;/P&gt;&lt;P&gt;set wmcustomer_name = TableObject.GetCell(RowIter,1)&lt;/P&gt;&lt;P&gt;set wmcustomer_address = TableObject.GetCell(RowIter,2) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set wmcustomer_place = TableObject.GetCell(RowIter,3)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set wmcustomer_participantid = TableObject.GetCell(RowIter,4)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set wmcustomer_id = TableObject.GetCell(RowIter,5) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'Set SQL&lt;/P&gt;&lt;P&gt;objRecordSet.Open _&lt;/P&gt;&lt;P&gt;&amp;nbsp; "INSERT INTO wm_customers " &amp;amp; _&lt;/P&gt;&lt;P&gt;&amp;nbsp; "(wmcustomer_no,wmcustomer_name,wmcustomer_address,wmcustomer_place,wmcustomer_participantid,wmcustomer_id ) " &amp;amp; _&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "VALUES ('"&amp;amp;wmcustomer_no.text&amp;amp;"', '"&amp;amp;wmcustomer_name.text&amp;amp;"', '"&amp;amp;wmcustomer_address.text&amp;amp;"', '"&amp;amp;wmcustomer_place.text&amp;amp;"', '"&amp;amp;wmcustomer_participantid.text&amp;amp;"', '"&amp;amp;wmcustomer_id.text&amp;amp;"')", _&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; objConnection, adOpenStatic, _&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; adLockOptimistic&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set objRecordSet = Nothing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;objConnection.Close&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set objConnection = Nothing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Application.Quit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ActiveDocument.GetApplication.Quit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2017 01:45:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-keeps-running-after-closing-document/m-p/1432414#M430708</guid>
      <dc:creator>tabletuner</dc:creator>
      <dc:date>2017-11-08T01:45:29Z</dc:date>
    </item>
  </channel>
</rss>

