<?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: VB Script help needed in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/VB-Script-help-needed/m-p/169179#M32440</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;While no one here responded to my question, I did get some help from the folks over on the SAS-L listserv.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;For anyone who might face a similar problem, the problems turns out to be that some versions of Excel obliterate one’s clipboard upon opening. As such, we had to modify the code to accommodate users who confront such a problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The solution can be found in our latest revision to the code at: &lt;A href="http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export"&gt;http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The solution, basically, was rather than copy to one’s clipboard, write the data to a file, and then in one vb script, open Excel, open the file in Notepad, copy the text, and then paste it into Excel. A bit clumsy, maybe, but it only took a few minutes to incorporate the code, only affects users who need the work around, and lets more people benefit from the macro’s capabilities.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;If you aren’t aware of the macro, it lets one export data to Excel, include or exclude a row of variable names or labels, use or not use formatted data, copy data to a non-pre-defined range, take advantage of Excel templates, and both create new workbooks, add a new worksheet, or modify an existing worksheet.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Art&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Jan 2015 21:57:52 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2015-01-09T21:57:52Z</dc:date>
    <item>
      <title>VB Script help needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/VB-Script-help-needed/m-p/169178#M32439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A macro included in a paper a group of us wrote last year write and runs some VB script in order to paste SAS data into Excel (see: &lt;A href="http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export" title="http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export"&gt;A Poor/Rich SAS Users Proc Export - sasCommunity&lt;/A&gt; ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Given a case where one is creating a new workbook (c:\temp\test\tclass1.xlsx), with one worksheet called N1, has copied the data from sashelp.class into their system's clipboard, and wants to paste the data into that worksheet, the macro creates and runs the following VB script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim objExcel&lt;/P&gt;&lt;P&gt;Dim Newbook&lt;/P&gt;&lt;P&gt;Dim NewSheet&lt;/P&gt;&lt;P&gt;Dim inSheetCount&lt;/P&gt;&lt;P&gt;Set objExcel = CreateObject("Excel.Application")&lt;/P&gt;&lt;P&gt;Set Newbook = objExcel.Workbooks.Add()&lt;/P&gt;&lt;P&gt;objExcel.Visible = True&lt;/P&gt;&lt;P&gt;inSheetCount = Newbook.Application.Worksheets.Count&lt;/P&gt;&lt;P&gt;set NewSheet = Newbook.Sheets.Add( ,objExcel.WorkSheets(inSheetCount))&lt;/P&gt;&lt;P&gt;objExcel.DisplayAlerts = False&lt;/P&gt;&lt;P&gt;i = inSheetCount&lt;/P&gt;&lt;P&gt;Do Until i = 0&lt;/P&gt;&lt;P&gt; Newbook.Worksheets(i).Delete&lt;/P&gt;&lt;P&gt; i = i - 1&lt;/P&gt;&lt;P&gt; Loop&lt;/P&gt;&lt;P&gt;Newbook.Sheets(1).Name="N1"&lt;/P&gt;&lt;P&gt;Newbook.Sheets("N1").Select&lt;/P&gt;&lt;P&gt;Newbook.Sheets("N1").Range("A2").Activate&lt;/P&gt;&lt;P&gt;Newbook.Sheets("N1").Paste&lt;/P&gt;&lt;P&gt;NewSheet.SaveAs("c:\temp\test\tclass1.xlsx")&lt;/P&gt;&lt;P&gt;objExcel.Workbooks.Close&lt;/P&gt;&lt;P&gt;objExcel.DisplayAlerts = True&lt;/P&gt;&lt;P&gt;objExcel.Quit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the script is failing for some users, in that Excel is returning the following error: Paste method of Worksheet class failed. We tried changing &lt;SPAN style="font-size: 13.63636302948px;"&gt;Newbook.Sheets("N1").Paste to &lt;SPAN style="font-size: 13.63636302948px;"&gt;Newbook.Sheets("N1").PasteSpecial, but that didn't correct the problem.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestion(s) on what should be changed to the VB script in order to get around that error?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Jan 2015 16:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/VB-Script-help-needed/m-p/169178#M32439</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-01-05T16:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: VB Script help needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/VB-Script-help-needed/m-p/169179#M32440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;While no one here responded to my question, I did get some help from the folks over on the SAS-L listserv.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;For anyone who might face a similar problem, the problems turns out to be that some versions of Excel obliterate one’s clipboard upon opening. As such, we had to modify the code to accommodate users who confront such a problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The solution can be found in our latest revision to the code at: &lt;A href="http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export"&gt;http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;The solution, basically, was rather than copy to one’s clipboard, write the data to a file, and then in one vb script, open Excel, open the file in Notepad, copy the text, and then paste it into Excel. A bit clumsy, maybe, but it only took a few minutes to incorporate the code, only affects users who need the work around, and lets more people benefit from the macro’s capabilities.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;If you aren’t aware of the macro, it lets one export data to Excel, include or exclude a row of variable names or labels, use or not use formatted data, copy data to a non-pre-defined range, take advantage of Excel templates, and both create new workbooks, add a new worksheet, or modify an existing worksheet.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Art&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jan 2015 21:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/VB-Script-help-needed/m-p/169179#M32440</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-01-09T21:57:52Z</dc:date>
    </item>
  </channel>
</rss>

