<?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: Send an excel to an email list acording to a selection in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-Send-an-excel-to-an-email-list-acording-to-a-selection/m-p/508087#M189948</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello QlikView Gurus, I'm here againh with anoter question, this one regarding a macro we have.&lt;/P&gt;&lt;P&gt;We have a document we want to automatize, so every morning sends an excel with the information about yesterday sales to a email list. The thing is, we want to send each person an excel with the info from their sucursal only, nothing else. We can filter by sucursal, but the thing is, I haven't found a way to use something like a "for" or "foreach" cycle to automatize the sucursal selection. This is my Macro script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;sub ExcelVentas&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; Set v = ActiveDocument.Variables ("vEmail")&lt;/P&gt;
&lt;P&gt;&amp;nbsp; activedocument.fields("SUCURSAL_DESC").select "1102 - CONSTITUCION"&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Email=v.GetContent.String&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; Path = "C:\temp\"&lt;/P&gt;
&lt;P&gt; FileName = "Test_Constitucion.xlsx"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; set XLApp = CreateObject("Excel.Application")&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; XLApp.Visible = False&lt;/P&gt;
&lt;P&gt; set XLDoc = XLApp.Workbooks.Add&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; ActiveDocument.GetSheetObject("CH04").CopyTableToClipboard true&lt;/P&gt;
&lt;P&gt; XLDoc.Sheets(1).Paste()&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; XLDoc.Sheets(1).Columns("A:W").EntireColumn.AutoFit&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; XLDoc.Sheets(1).Name = "Export"&lt;/P&gt;
&lt;P&gt; XLDoc.SaveAs Path &amp;amp; FileName&lt;/P&gt;
&lt;P&gt; XLApp.Quit&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; Set myApp = CreateObject ("Outlook.Application")&lt;/P&gt;
&lt;P&gt; Set myMessage = myApp.CreateItem(olMailItem)&lt;/P&gt;
&lt;P&gt; myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; myMessage.To = Email&lt;/P&gt;
&lt;P&gt; myMessage.Attachments.Add "C:\temp\" &amp;amp; FileName&lt;/P&gt;
&lt;P&gt; myMessage.Subject = "Test File " &amp;amp; Date()&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; myMessage.Send&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Set myMessage = Nothing &lt;/P&gt;
&lt;P&gt;Set myApp = Nothing&lt;/P&gt;
&lt;P&gt;Set myInspector = Nothing&lt;/P&gt;
&lt;P&gt;Set myDoc = Nothing&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;end sub&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see, on this part: "&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif;"&gt;&lt;SPAN&gt;activedocument.fields("SUCURSAL_DESC").select "1102 - CONSTITUCION" we pass the macro automatically the sucursal we want to use, and on this one: "Set v = ActiveDocument.Variables ("vEmail")" we use a variable, vEmail, so the user can write the list of people who are going to recibe the excel. The main goal is, having a list of people for each sucursal, use ana utomated script so, for example, &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:mail1@xyz.com"&gt;mail1@xyz.com&lt;/A&gt;&lt;SPAN&gt; reciebes the info from the sucursal 1 already filtered, &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:mail2@xyz.com"&gt;mail2@xyz.com&lt;/A&gt;&lt;SPAN&gt; reciebes info from sucursal 3, and so on.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help you can give me? Im not very good programming on VB or Java, so any help is apreciated. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Oct 2013 21:53:22 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-10-22T21:53:22Z</dc:date>
    <item>
      <title>Macro: Send an excel to an email list acording to a selection</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-Send-an-excel-to-an-email-list-acording-to-a-selection/m-p/508087#M189948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello QlikView Gurus, I'm here againh with anoter question, this one regarding a macro we have.&lt;/P&gt;&lt;P&gt;We have a document we want to automatize, so every morning sends an excel with the information about yesterday sales to a email list. The thing is, we want to send each person an excel with the info from their sucursal only, nothing else. We can filter by sucursal, but the thing is, I haven't found a way to use something like a "for" or "foreach" cycle to automatize the sucursal selection. This is my Macro script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;sub ExcelVentas&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; Set v = ActiveDocument.Variables ("vEmail")&lt;/P&gt;
&lt;P&gt;&amp;nbsp; activedocument.fields("SUCURSAL_DESC").select "1102 - CONSTITUCION"&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Email=v.GetContent.String&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; Path = "C:\temp\"&lt;/P&gt;
&lt;P&gt; FileName = "Test_Constitucion.xlsx"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; set XLApp = CreateObject("Excel.Application")&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; XLApp.Visible = False&lt;/P&gt;
&lt;P&gt; set XLDoc = XLApp.Workbooks.Add&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; ActiveDocument.GetSheetObject("CH04").CopyTableToClipboard true&lt;/P&gt;
&lt;P&gt; XLDoc.Sheets(1).Paste()&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; XLDoc.Sheets(1).Columns("A:W").EntireColumn.AutoFit&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; XLDoc.Sheets(1).Name = "Export"&lt;/P&gt;
&lt;P&gt; XLDoc.SaveAs Path &amp;amp; FileName&lt;/P&gt;
&lt;P&gt; XLApp.Quit&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; Set myApp = CreateObject ("Outlook.Application")&lt;/P&gt;
&lt;P&gt; Set myMessage = myApp.CreateItem(olMailItem)&lt;/P&gt;
&lt;P&gt; myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; myMessage.To = Email&lt;/P&gt;
&lt;P&gt; myMessage.Attachments.Add "C:\temp\" &amp;amp; FileName&lt;/P&gt;
&lt;P&gt; myMessage.Subject = "Test File " &amp;amp; Date()&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; myMessage.Send&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Set myMessage = Nothing &lt;/P&gt;
&lt;P&gt;Set myApp = Nothing&lt;/P&gt;
&lt;P&gt;Set myInspector = Nothing&lt;/P&gt;
&lt;P&gt;Set myDoc = Nothing&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;end sub&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see, on this part: "&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif;"&gt;&lt;SPAN&gt;activedocument.fields("SUCURSAL_DESC").select "1102 - CONSTITUCION" we pass the macro automatically the sucursal we want to use, and on this one: "Set v = ActiveDocument.Variables ("vEmail")" we use a variable, vEmail, so the user can write the list of people who are going to recibe the excel. The main goal is, having a list of people for each sucursal, use ana utomated script so, for example, &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:mail1@xyz.com"&gt;mail1@xyz.com&lt;/A&gt;&lt;SPAN&gt; reciebes the info from the sucursal 1 already filtered, &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:mail2@xyz.com"&gt;mail2@xyz.com&lt;/A&gt;&lt;SPAN&gt; reciebes info from sucursal 3, and so on.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help you can give me? Im not very good programming on VB or Java, so any help is apreciated. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 21:53:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-Send-an-excel-to-an-email-list-acording-to-a-selection/m-p/508087#M189948</guid>
      <dc:creator />
      <dc:date>2013-10-22T21:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Macro: Send an excel to an email list acording to a selection</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-Send-an-excel-to-an-email-list-acording-to-a-selection/m-p/508088#M189949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PFA SAmple Hope this will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vikas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Oct 2013 09:29:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-Send-an-excel-to-an-email-list-acording-to-a-selection/m-p/508088#M189949</guid>
      <dc:creator>vikasmahajan</dc:creator>
      <dc:date>2013-10-23T09:29:30Z</dc:date>
    </item>
  </channel>
</rss>

