<?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: Rename file with Macro based on current selection in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Rename-file-with-Macro-based-on-current-selection/m-p/532002#M198739</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nils,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case you were still looking for a way to do that, here's a sample code (change to correct field, filename and extension, set the security flag to "allow system access"):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub RenameFileBasedOnSelection&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set vFld = ActiveDocument.Fields("Child").GetSelectedValues&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if vFld.Count &amp;gt; 0 then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vSelected = vFld.Item(0).text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i = 1 to vFld.Count - 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vSelected = vSelected &amp;amp; ", " &amp;amp; vFld.Item(i).text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set obj = CreateObject("Scripting.FileSystemObject")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strFile = "C:\Users\Test\Desktop\QVW\s.csv"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strRename = "C:\Users\Test\Desktop\QVW\" &amp;amp; vSelected &amp;amp; ".csv"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if obj.FileExists(strFile) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj.MoveFile strFile, strRename&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msgbox("File Doesn't Exist")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end if&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set obj = nothing&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msgbox("Please select at least one value")&lt;/P&gt;&lt;P&gt;end if&lt;/P&gt;&lt;P&gt;&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;Hope this will help you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 29 Dec 2013 22:02:06 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-12-29T22:02:06Z</dc:date>
    <item>
      <title>Rename file with Macro based on current selection</title>
      <link>https://community.qlik.com/t5/QlikView/Rename-file-with-Macro-based-on-current-selection/m-p/532001#M198738</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 have been struggling with a macro to rename a file. The background is that I have an action that prints a report with PDF exchange 3.0, the report is generated and saved to a predefined location (set in the printer settings) so far so good.&amp;nbsp; The problem is that the output file is always the same name (QlikView Printing) what I need to do is rename this file based on a selection mande in a field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, if the user selects USA in the Region field then I need the output pdf to be renamed as USA.pdf.&lt;/P&gt;&lt;P&gt;I have used to function ActiveDocument.Fields("Region").GetPossibleValues&amp;nbsp; but I am not sure how to pass this to the filename.&lt;/P&gt;&lt;P&gt;I have done this before using a timestamp function but cannot get the selected value into the filename.&lt;/P&gt;&lt;P&gt;Any Ideas? Example code would be great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I should also mention that I am well aware of 3rd party solutions such as Nprinting that would solve this problem but in this case this is not an option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2013 07:57:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Rename-file-with-Macro-based-on-current-selection/m-p/532001#M198738</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-12-05T07:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Rename file with Macro based on current selection</title>
      <link>https://community.qlik.com/t5/QlikView/Rename-file-with-Macro-based-on-current-selection/m-p/532002#M198739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nils,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case you were still looking for a way to do that, here's a sample code (change to correct field, filename and extension, set the security flag to "allow system access"):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub RenameFileBasedOnSelection&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set vFld = ActiveDocument.Fields("Child").GetSelectedValues&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if vFld.Count &amp;gt; 0 then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vSelected = vFld.Item(0).text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i = 1 to vFld.Count - 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vSelected = vSelected &amp;amp; ", " &amp;amp; vFld.Item(i).text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set obj = CreateObject("Scripting.FileSystemObject")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strFile = "C:\Users\Test\Desktop\QVW\s.csv"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strRename = "C:\Users\Test\Desktop\QVW\" &amp;amp; vSelected &amp;amp; ".csv"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if obj.FileExists(strFile) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj.MoveFile strFile, strRename&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msgbox("File Doesn't Exist")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end if&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set obj = nothing&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msgbox("Please select at least one value")&lt;/P&gt;&lt;P&gt;end if&lt;/P&gt;&lt;P&gt;&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;Hope this will help you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Dec 2013 22:02:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Rename-file-with-Macro-based-on-current-selection/m-p/532002#M198739</guid>
      <dc:creator />
      <dc:date>2013-12-29T22:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Rename file with Macro based on current selection</title>
      <link>https://community.qlik.com/t5/QlikView/Rename-file-with-Macro-based-on-current-selection/m-p/532003#M198740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks this does the trick!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Dec 2013 08:38:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Rename-file-with-Macro-based-on-current-selection/m-p/532003#M198740</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-12-30T08:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rename file with Macro based on current selection</title>
      <link>https://community.qlik.com/t5/QlikView/Rename-file-with-Macro-based-on-current-selection/m-p/1653388#M447995</link>
      <description>&lt;P&gt;Wounderful, when you once in switzerland let me know. your earned minimum one lunch with me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2019 03:15:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Rename-file-with-Macro-based-on-current-selection/m-p/1653388#M447995</guid>
      <dc:creator>romanp</dc:creator>
      <dc:date>2019-12-03T03:15:49Z</dc:date>
    </item>
  </channel>
</rss>

