<?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: Consolidate Multpile Excel Sheets into One Workbook in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Consolidate-Multpile-Excel-Sheets-into-One-Workbook/m-p/540512#M149112</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38234"&gt;@angeliquec&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, X Commands are disabled in our SAS server, and won't be enabled. With that, I'd like to know how can I execute a vb script I made for the consolidation of these multiple excel sheets. I know it's possible to fix the sequence using ODS tagsets, but since there is a lot of ongoing program development and revision, I prefer to perform the consolidation at the end of my SAS program.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VB Script sample as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Function Cpypaste (xlfile)&lt;BR /&gt;Dim xlfile_nm&lt;BR /&gt;xlfile_nm = xlfile&lt;BR /&gt;'MsgBox xlfile_nm&lt;BR /&gt;Set CopyFromWbk = objExcel.Workbooks.Open(FolderPath &amp;amp; xlfile_nm &amp;amp; ".xlsx")&lt;BR /&gt;'Worksheet.Name = xlfile_nm&lt;BR /&gt;Set ShToCopy = CopyFromWbk.Sheets(1)&lt;BR /&gt;ShToCopy.Copy CopyToWbk.Sheets(CopyToWbk.Sheets.Count)&lt;BR /&gt;CopyFromWbk.Close&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;End Function&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you are generating that output to multiple sheets from SAS then likely you could just change how the output is generated from SAS.&lt;/P&gt;
&lt;P&gt;If using ODS&amp;nbsp; tagsets.excelxp or ods excel then the SHEET_INTERVAL option controls how sheets are generated and likely use of NONE would send all of the output to a single sheet so the post processing is not needed.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Mar 2019 17:30:37 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-03-05T17:30:37Z</dc:date>
    <item>
      <title>Consolidate Multpile Excel Sheets into One Workbook</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Consolidate-Multpile-Excel-Sheets-into-One-Workbook/m-p/540309#M149024</link>
      <description>&lt;P&gt;Hi, X Commands are disabled in our SAS server, and won't be enabled. With that, I'd like to know how can I execute a vb script I made for the consolidation of these multiple excel sheets. I know it's possible to fix the sequence using ODS tagsets, but since there is a lot of ongoing program development and revision, I prefer to perform the consolidation at the end of my SAS program.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VB Script sample as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Function Cpypaste (xlfile)&lt;BR /&gt;Dim xlfile_nm&lt;BR /&gt;xlfile_nm = xlfile&lt;BR /&gt;'MsgBox xlfile_nm&lt;BR /&gt;Set CopyFromWbk = objExcel.Workbooks.Open(FolderPath &amp;amp; xlfile_nm &amp;amp; ".xlsx")&lt;BR /&gt;'Worksheet.Name = xlfile_nm&lt;BR /&gt;Set ShToCopy = CopyFromWbk.Sheets(1)&lt;BR /&gt;ShToCopy.Copy CopyToWbk.Sheets(CopyToWbk.Sheets.Count)&lt;BR /&gt;CopyFromWbk.Close&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;End Function&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 03:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Consolidate-Multpile-Excel-Sheets-into-One-Workbook/m-p/540309#M149024</guid>
      <dc:creator>angeliquec</dc:creator>
      <dc:date>2019-03-05T03:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Consolidate Multpile Excel Sheets into One Workbook</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Consolidate-Multpile-Excel-Sheets-into-One-Workbook/m-p/540339#M149034</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;maybe something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro consolidateXlsxSheets(FolderPath=,xlfile=,vbsFileName=);

   %let saveOpt=%sysfunc(getOption(QUOTELENMAX));
   options noquotelenmax;
   data _null_;
      file "&amp;amp;vbsFileName";
      put " Dim objExcel ";
      put " Dim FSO";
      put " Dim objWorkBook";
      put " Set objExcel = CreateObject(""Excel.Application"")";
      put " Set FSO = CreateObject(""Scripting.FileSystemObject"")";

      put " objExcel.DisplayAlerts = False";
    
      put " Dim xlfile_nm";
      put " xlfile_nm = &amp;amp;xlfile.";
      put " 'MsgBox xlfile_nm";
      put " Set CopyFromWbk = objExcel.Workbooks.Open(&amp;amp;FolderPath. &amp;amp; xlfile_nm &amp;amp; "".xlsx"")";
      put " 'Worksheet.Name = xlfile_nm";
      put " Set ShToCopy = CopyFromWbk.Sheets(1)";
      put " ShToCopy.Copy CopyToWbk.Sheets(CopyToWbk.Sheets.Count)";
      put " CopyFromWbk.Close";

      put " objExcel.DisplayAlerts = True";
      put " objExcel.Quit";
      put " Set objExcel = Nothing";
      put " FSO.DeleteFile(""&amp;amp;vbsFileName""), DeleteReadOnly";
      put " Set FSO = Nothing"; 
   run;
   data _null_;
      call system("""&amp;amp;vbsFileName"""); * 3 quotes in order to work with names containing spaces;
   run;
   options &amp;amp;saveOpt.;
%mend consolidateXlsxSheets;
%consolidateXlsxSheets(FolderPath=,xlfile=,vbsFileName=c:\xyz.vbs);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Mar 2019 06:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Consolidate-Multpile-Excel-Sheets-into-One-Workbook/m-p/540339#M149034</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2019-03-05T06:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Consolidate Multpile Excel Sheets into One Workbook</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Consolidate-Multpile-Excel-Sheets-into-One-Workbook/m-p/540346#M149038</link>
      <description>&lt;P&gt;Thanks! It's a working alternative to the X statement, but I'm still getting a Shell Escape not valid error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 07:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Consolidate-Multpile-Excel-Sheets-into-One-Workbook/m-p/540346#M149038</guid>
      <dc:creator>angeliquec</dc:creator>
      <dc:date>2019-03-05T07:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Consolidate Multpile Excel Sheets into One Workbook</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Consolidate-Multpile-Excel-Sheets-into-One-Workbook/m-p/540512#M149112</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38234"&gt;@angeliquec&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, X Commands are disabled in our SAS server, and won't be enabled. With that, I'd like to know how can I execute a vb script I made for the consolidation of these multiple excel sheets. I know it's possible to fix the sequence using ODS tagsets, but since there is a lot of ongoing program development and revision, I prefer to perform the consolidation at the end of my SAS program.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;VB Script sample as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Function Cpypaste (xlfile)&lt;BR /&gt;Dim xlfile_nm&lt;BR /&gt;xlfile_nm = xlfile&lt;BR /&gt;'MsgBox xlfile_nm&lt;BR /&gt;Set CopyFromWbk = objExcel.Workbooks.Open(FolderPath &amp;amp; xlfile_nm &amp;amp; ".xlsx")&lt;BR /&gt;'Worksheet.Name = xlfile_nm&lt;BR /&gt;Set ShToCopy = CopyFromWbk.Sheets(1)&lt;BR /&gt;ShToCopy.Copy CopyToWbk.Sheets(CopyToWbk.Sheets.Count)&lt;BR /&gt;CopyFromWbk.Close&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;End Function&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you are generating that output to multiple sheets from SAS then likely you could just change how the output is generated from SAS.&lt;/P&gt;
&lt;P&gt;If using ODS&amp;nbsp; tagsets.excelxp or ods excel then the SHEET_INTERVAL option controls how sheets are generated and likely use of NONE would send all of the output to a single sheet so the post processing is not needed.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 17:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Consolidate-Multpile-Excel-Sheets-into-One-Workbook/m-p/540512#M149112</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-05T17:30:37Z</dc:date>
    </item>
  </channel>
</rss>

