<?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 Convert XLS to XLSX in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-XLS-to-XLSX/m-p/894433#M43683</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Pls help Code not properly work &lt;BR /&gt;&lt;BR /&gt;%let path=/desreports;

ods tagsets.excelxp file="&amp;amp;path/temp.XLS" Style=my.style;
data class; set sashelp.class; run;

proc report data=class; run;

ods tagsets.excelxp close;

%convert_files(default=&amp;amp;path,ext=XLS);

/*------------------------------Convert () to XLSX--------------------------------*/
 options noxwait noxsync; 
 
%macro convert_files(default=,ext=);
 
data _null_;
file "'&amp;amp;default/temp.vbs'";
put "set xlapp = CreateObject(""Excel.Application"")";
put "set fso = CreateObject(""scripting.filesystemobject"")";
put "set myfolder = fso.GetFolder(""&amp;amp;default"")";
put "set myfiles = myfolder.Files";
put "xlapp.DisplayAlerts = False";
put " ";
put "for each f in myfiles";
put "  ExtName = fso.GetExtensionName(f)";
put "  Filename= fso.GetBaseName(f)";
put "    if ExtName=""&amp;amp;ext"" then";
put "           set mybook = xlapp.Workbooks.Open(f.Path)"; 
put "           xlapp.Visible = false";
put "           mybook.SaveAs ""&amp;amp;default./"" &amp;amp; Filename &amp;amp; "".xlsx"", 51";
put "    End If";
put "  Next";
put "  mybook.Close";
put "  xlapp.DisplayAlerts = True";
/* Removes original files */
put " FSO.DeleteFile(""&amp;amp;default/*.&amp;amp;ext""), DeleteReadOnly";
put " xlapp.Quit";
put " Set xlapp = Nothing";
put " strScript = Wscript.ScriptFullName";
put " FSO.DeleteFile(strScript)"; 
run; 
 
x "cscript ""&amp;amp;default/temp.vbs""";
 
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Sep 2023 06:48:33 GMT</pubDate>
    <dc:creator>Daily1</dc:creator>
    <dc:date>2023-09-15T06:48:33Z</dc:date>
    <item>
      <title>Convert XLS to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-XLS-to-XLSX/m-p/894433#M43683</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Pls help Code not properly work &lt;BR /&gt;&lt;BR /&gt;%let path=/desreports;

ods tagsets.excelxp file="&amp;amp;path/temp.XLS" Style=my.style;
data class; set sashelp.class; run;

proc report data=class; run;

ods tagsets.excelxp close;

%convert_files(default=&amp;amp;path,ext=XLS);

/*------------------------------Convert () to XLSX--------------------------------*/
 options noxwait noxsync; 
 
%macro convert_files(default=,ext=);
 
data _null_;
file "'&amp;amp;default/temp.vbs'";
put "set xlapp = CreateObject(""Excel.Application"")";
put "set fso = CreateObject(""scripting.filesystemobject"")";
put "set myfolder = fso.GetFolder(""&amp;amp;default"")";
put "set myfiles = myfolder.Files";
put "xlapp.DisplayAlerts = False";
put " ";
put "for each f in myfiles";
put "  ExtName = fso.GetExtensionName(f)";
put "  Filename= fso.GetBaseName(f)";
put "    if ExtName=""&amp;amp;ext"" then";
put "           set mybook = xlapp.Workbooks.Open(f.Path)"; 
put "           xlapp.Visible = false";
put "           mybook.SaveAs ""&amp;amp;default./"" &amp;amp; Filename &amp;amp; "".xlsx"", 51";
put "    End If";
put "  Next";
put "  mybook.Close";
put "  xlapp.DisplayAlerts = True";
/* Removes original files */
put " FSO.DeleteFile(""&amp;amp;default/*.&amp;amp;ext""), DeleteReadOnly";
put " xlapp.Quit";
put " Set xlapp = Nothing";
put " strScript = Wscript.ScriptFullName";
put " FSO.DeleteFile(strScript)"; 
run; 
 
x "cscript ""&amp;amp;default/temp.vbs""";
 
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2023 06:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-XLS-to-XLSX/m-p/894433#M43683</guid>
      <dc:creator>Daily1</dc:creator>
      <dc:date>2023-09-15T06:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XLS to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-XLS-to-XLSX/m-p/894435#M43684</link>
      <description>&lt;P&gt;You don't specify what the issue is but you are using VBS which is not a recommended language.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look here:&amp;nbsp;&lt;A href="https://office-watch.com/2023/bulk-conversion-old-office-documents-to-new-formats/" target="_blank"&gt;Bulk conversion of old Office documents to new formats - Office Watch (office-watch.com)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Easy to also do in VBA, C#, probably Python, and a number of others. If the goal is to just do this once, use a utility. If not, use a better scripting language than VBS. Consider a simple command line utility.&amp;nbsp; Look here:&amp;nbsp;&lt;A href="https://gist.github.com/Opiprog/8bb6f491578d4f23540ccd98e85288c3#file-gistfile1-txt" target="_blank"&gt;Convert xls to xlsx using Windows cmd · GitHub&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use commercial tools to do this and it is literally 3 lines. There are loads of utilities to help. Just use the X command in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to do this in VBS, get it to work first then wrap in PUT statements.&amp;nbsp; I just uploaded an old program to github you can use to do the put statements with what you created. I will add source code later.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See:&amp;nbsp;&lt;A href="https://github.com/savian-net/SaviPut" target="_blank"&gt;savian-net/SaviPut: Takes any text and wraps it in SAS put statements (github.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2023 07:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-XLS-to-XLSX/m-p/894435#M43684</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2023-09-15T07:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Convert XLS to XLSX</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-XLS-to-XLSX/m-p/894473#M43686</link>
      <description>&lt;P&gt;If this is just about using SAS to create *.xls&lt;STRONG&gt;x&lt;/STRONG&gt; files instead of *.xls then use destination ODS EXCEL instead of the outdated ODS tagset.exelxp.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2023 12:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-XLS-to-XLSX/m-p/894473#M43686</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-09-15T12:50:26Z</dc:date>
    </item>
  </channel>
</rss>

