<?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 Create folder and sub folder to save exported file in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Create-folder-and-sub-folder-to-save-exported-file/m-p/1792591#M1210823</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to export to Pivot tables and a Line chart to an excel file. I have used the below code. In this case, it asks me where to save the file, &lt;U&gt;&lt;STRONG&gt;but I want it to be saved in a particular folder while creating year and month folder itself.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;For eg: It saves in&amp;nbsp;\\FO\MO\TLM\2021\March wherein the year (2021) and month(March) is created dynamically so that it changes with change in year and month&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sub Export&lt;BR /&gt;Dim objShell&lt;BR /&gt;Dim objFolder&lt;BR /&gt;Dim excelFile&lt;BR /&gt;Dim curWorkBook&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Set objShell = CreateObject("Shell.Application")&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Set objFolder = objShell.BrowseForFolder(0, "Select the path to save the excel:", 1, "Computer")&lt;BR /&gt;&amp;nbsp;&amp;nbsp; On Error Resume Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If objFolder Is Nothing Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objShell = nothing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objFolder = nothing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit sub&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;BR /&gt;&amp;nbsp;'File name&lt;BR /&gt;&amp;nbsp;FileName = "ABC") &amp;amp; ".xlsx"&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Create the Excel spreadsheet&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set excelFile = CreateObject("Excel.Application")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; excelFile.Visible = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Create the WorkBook&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set curWorkBook = excelFile.WorkBooks.Add&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Create the Sheet&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set curSheet = curWorkBook.WorkSheets(1)&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Get the chart we want to export&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set tableToExport = ActiveDocument.GetSheetObject("Break Volume")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set chartProperties = tableToExport.GetProperties&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableToExport.CopyTableToClipboard true&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'Get the caption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chartCaption = tableToExport.GetCaption.Name.v&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'MsgBox chartCaption&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Set the first cell with the caption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curSheet.Range("A1") = chartCaption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Paste the rest of the chart&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curSheet.Paste curSheet.Range("A2")&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Get the chart we want to export&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set tableToExport = ActiveDocument.GetSheetObject("Break Scenerio")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set chartProperties = tableToExport.GetProperties&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableToExport.CopyTableToClipboard true&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'Get the caption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chartCaption = tableToExport.GetCaption.Name.v&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'MsgBox chartCaption&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Set the first cell with the caption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curSheet.Range("J1") = chartCaption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Paste the rest of the chart&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curSheet.Paste curSheet.Range("J2")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Save the file and quit excel&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curWorkBook.SaveAs objFolder.self.path &amp;amp; "\" &amp;amp;&amp;nbsp; FileName&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curWorkBook.Close&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; excelFile.Quit&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Msgbox "File exported successfully!!"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Cleanup&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objShell = nothing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objFolder = nothing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set curWorkBook = nothing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set excelFile = nothing&lt;BR /&gt;End Sub&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Mar 2021 14:52:35 GMT</pubDate>
    <dc:creator>arpita</dc:creator>
    <dc:date>2021-03-18T14:52:35Z</dc:date>
    <item>
      <title>Create folder and sub folder to save exported file</title>
      <link>https://community.qlik.com/t5/QlikView/Create-folder-and-sub-folder-to-save-exported-file/m-p/1792591#M1210823</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to export to Pivot tables and a Line chart to an excel file. I have used the below code. In this case, it asks me where to save the file, &lt;U&gt;&lt;STRONG&gt;but I want it to be saved in a particular folder while creating year and month folder itself.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;For eg: It saves in&amp;nbsp;\\FO\MO\TLM\2021\March wherein the year (2021) and month(March) is created dynamically so that it changes with change in year and month&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sub Export&lt;BR /&gt;Dim objShell&lt;BR /&gt;Dim objFolder&lt;BR /&gt;Dim excelFile&lt;BR /&gt;Dim curWorkBook&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Set objShell = CreateObject("Shell.Application")&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Set objFolder = objShell.BrowseForFolder(0, "Select the path to save the excel:", 1, "Computer")&lt;BR /&gt;&amp;nbsp;&amp;nbsp; On Error Resume Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If objFolder Is Nothing Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objShell = nothing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objFolder = nothing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit sub&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;BR /&gt;&amp;nbsp;'File name&lt;BR /&gt;&amp;nbsp;FileName = "ABC") &amp;amp; ".xlsx"&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Create the Excel spreadsheet&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set excelFile = CreateObject("Excel.Application")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; excelFile.Visible = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Create the WorkBook&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set curWorkBook = excelFile.WorkBooks.Add&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Create the Sheet&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set curSheet = curWorkBook.WorkSheets(1)&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Get the chart we want to export&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set tableToExport = ActiveDocument.GetSheetObject("Break Volume")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set chartProperties = tableToExport.GetProperties&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableToExport.CopyTableToClipboard true&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'Get the caption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chartCaption = tableToExport.GetCaption.Name.v&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'MsgBox chartCaption&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Set the first cell with the caption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curSheet.Range("A1") = chartCaption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Paste the rest of the chart&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curSheet.Paste curSheet.Range("A2")&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Get the chart we want to export&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set tableToExport = ActiveDocument.GetSheetObject("Break Scenerio")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set chartProperties = tableToExport.GetProperties&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tableToExport.CopyTableToClipboard true&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;'Get the caption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; chartCaption = tableToExport.GetCaption.Name.v&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'MsgBox chartCaption&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Set the first cell with the caption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curSheet.Range("J1") = chartCaption&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Paste the rest of the chart&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curSheet.Paste curSheet.Range("J2")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Save the file and quit excel&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curWorkBook.SaveAs objFolder.self.path &amp;amp; "\" &amp;amp;&amp;nbsp; FileName&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; curWorkBook.Close&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; excelFile.Quit&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Msgbox "File exported successfully!!"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Cleanup&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objShell = nothing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set objFolder = nothing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set curWorkBook = nothing&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set excelFile = nothing&lt;BR /&gt;End Sub&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 14:52:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-folder-and-sub-folder-to-save-exported-file/m-p/1792591#M1210823</guid>
      <dc:creator>arpita</dc:creator>
      <dc:date>2021-03-18T14:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create folder and sub folder to save exported file</title>
      <link>https://community.qlik.com/t5/QlikView/Create-folder-and-sub-folder-to-save-exported-file/m-p/1793099#M1210880</link>
      <description>&lt;P&gt;Maybe like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Sub Export
Dim objShell
Dim objFolder
Dim excelFile
Dim curWorkBook

   'Set objShell = CreateObject("Shell.Application")
   'Set objFolder = objShell.BrowseForFolder(0, "Select the path to save the excel:", 1, "Computer")
'   On Error Resume Next
'      If objFolder Is Nothing Then
'        Set objShell = nothing
'        Set objFolder = nothing
'        Exit sub
'      End If
 'File name
 'FileName = "ABC") &amp;amp; ".xlsx"
 
     'Create the Excel spreadsheet 
     Set excelFile = CreateObject("Excel.Application")
     excelFile.Visible = False
     'Create the WorkBook
     Set curWorkBook = excelFile.WorkBooks.Add
     'Create the Sheet
     Set curSheet = curWorkBook.WorkSheets(1)
 
     'Get the chart we want to export
     Set tableToExport = ActiveDocument.GetSheetObject("Break Volume")
     Set chartProperties = tableToExport.GetProperties
     tableToExport.CopyTableToClipboard true
 
      'Get the caption
     chartCaption = tableToExport.GetCaption.Name.v
     'MsgBox chartCaption
 
     'Set the first cell with the caption
     curSheet.Range("A1") = chartCaption
     'Paste the rest of the chart
     curSheet.Paste curSheet.Range("A2")
 
 
     'Get the chart we want to export
     Set tableToExport = ActiveDocument.GetSheetObject("Break Scenerio")
     Set chartProperties = tableToExport.GetProperties
     tableToExport.CopyTableToClipboard true
 
      'Get the caption
     chartCaption = tableToExport.GetCaption.Name.v
     'MsgBox chartCaption
 
     'Set the first cell with the caption
     curSheet.Range("J1") = chartCaption
     'Paste the rest of the chart
     curSheet.Paste curSheet.Range("J2")
    
     set filesys=CreateObject("Scripting.FileSystemObject") 
     newfolderpath = "\\FO\MO\TLM\"&amp;amp;year(now())&amp;amp;"\"&amp;amp;month(now())
     Set newfolder = filesys.CreateFolder(newfolderpath)
 
     'Save the file and quit excel
     curWorkBook.SaveAs newfolderpath
     curWorkBook.Close
     excelFile.Quit
   
    Msgbox "File exported successfully!!"
     'Cleanup
     Set objShell = nothing
     Set objFolder = nothing
     Set curWorkBook = nothing
     Set excelFile = nothing
End Sub &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Mar 2021 20:45:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-folder-and-sub-folder-to-save-exported-file/m-p/1793099#M1210880</guid>
      <dc:creator>Frank_Hartmann</dc:creator>
      <dc:date>2021-03-20T20:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create folder and sub folder to save exported file</title>
      <link>https://community.qlik.com/t5/QlikView/Create-folder-and-sub-folder-to-save-exported-file/m-p/1793331#M1210901</link>
      <description>&lt;P&gt;Hi Frank,&lt;/P&gt;&lt;P&gt;this doesn't work&lt;/P&gt;</description>
      <pubDate>Mon, 22 Mar 2021 12:37:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-folder-and-sub-folder-to-save-exported-file/m-p/1793331#M1210901</guid>
      <dc:creator>arpita</dc:creator>
      <dc:date>2021-03-22T12:37:29Z</dc:date>
    </item>
  </channel>
</rss>

