<?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: Set password for excel in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Set-password-for-excel/m-p/69169#M7952</link>
    <description>I don't know of a SAS PROC or function, but you can write a program, that writes a program that calls a program that sets the PW.  Here in one example.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
filename IN  '.\book1.xls';&lt;BR /&gt;
filename OUT '.\book1PW.xls';&lt;BR /&gt;
%let PW = PWvalue;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   length script filevar command workbook1 workbook2 $256 pw $16;&lt;BR /&gt;
   script    = catx('\',pathname('WORK'),'PASSWORD.vbs');&lt;BR /&gt;
   filevar   = script;&lt;BR /&gt;
   workbook1 = pathname('in');&lt;BR /&gt;
   workbook2 = pathname('out');&lt;BR /&gt;
   pw        = symget('PW');&lt;BR /&gt;
&lt;BR /&gt;
   file dummy1 filevar=filevar;&lt;BR /&gt;
   put 'Const ' workbook1=$quote256.;&lt;BR /&gt;
   put 'Const ' workbook2=$quote256.;&lt;BR /&gt;
   put 'Const ' pw=$quote18.;&lt;BR /&gt;
   put 'Set objExcel = CreateObject("Excel.Application")';&lt;BR /&gt;
   put 'objExcel.Visible = FALSE';&lt;BR /&gt;
   put 'objExcel.DisplayAlerts = FALSE';&lt;BR /&gt;
   put 'Set objWorkbook  = objExcel.Workbooks.Open(workbook1)';&lt;BR /&gt;
&lt;BR /&gt;
   put 'objWorkbook.SaveAs workbook2,,pw';&lt;BR /&gt;
   put 'objExcel.Quit';&lt;BR /&gt;
&lt;BR /&gt;
   /* close the script file by opening another file */&lt;BR /&gt;
   filevar = catx('\',pathname('WORK'),'DUMMY2.vbs');&lt;BR /&gt;
   file dummy1 filevar=filevar;&lt;BR /&gt;
&lt;BR /&gt;
   /* look at the script, not necessary but may be useful */&lt;BR /&gt;
   infile dummy3 filevar=script end=eof;&lt;BR /&gt;
   do _n_ = 1 by 1 until(eof);&lt;BR /&gt;
      input;&lt;BR /&gt;
      putlog 'NOTE: ' _n_ 3. +1 _infile_;&lt;BR /&gt;
      end;&lt;BR /&gt;
&lt;BR /&gt;
   /* call the script */&lt;BR /&gt;
   command = catx(' ','cscript',quote(strip(script)));&lt;BR /&gt;
   infile dummy4 pipe filevar=command end=eof;&lt;BR /&gt;
   do until(eof);&lt;BR /&gt;
      input ;&lt;BR /&gt;
      putlog _infile_;&lt;BR /&gt;
      end;&lt;BR /&gt;
   stop;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Thu, 03 Sep 2009 13:23:08 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2009-09-03T13:23:08Z</dc:date>
    <item>
      <title>Set password for excel</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Set-password-for-excel/m-p/69168#M7951</link>
      <description>Hi,&lt;BR /&gt;
Is it possible to set a password for Excel book from within SAS (Base or EG)?</description>
      <pubDate>Thu, 03 Sep 2009 08:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Set-password-for-excel/m-p/69168#M7951</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-03T08:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Set password for excel</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Set-password-for-excel/m-p/69169#M7952</link>
      <description>I don't know of a SAS PROC or function, but you can write a program, that writes a program that calls a program that sets the PW.  Here in one example.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
filename IN  '.\book1.xls';&lt;BR /&gt;
filename OUT '.\book1PW.xls';&lt;BR /&gt;
%let PW = PWvalue;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   length script filevar command workbook1 workbook2 $256 pw $16;&lt;BR /&gt;
   script    = catx('\',pathname('WORK'),'PASSWORD.vbs');&lt;BR /&gt;
   filevar   = script;&lt;BR /&gt;
   workbook1 = pathname('in');&lt;BR /&gt;
   workbook2 = pathname('out');&lt;BR /&gt;
   pw        = symget('PW');&lt;BR /&gt;
&lt;BR /&gt;
   file dummy1 filevar=filevar;&lt;BR /&gt;
   put 'Const ' workbook1=$quote256.;&lt;BR /&gt;
   put 'Const ' workbook2=$quote256.;&lt;BR /&gt;
   put 'Const ' pw=$quote18.;&lt;BR /&gt;
   put 'Set objExcel = CreateObject("Excel.Application")';&lt;BR /&gt;
   put 'objExcel.Visible = FALSE';&lt;BR /&gt;
   put 'objExcel.DisplayAlerts = FALSE';&lt;BR /&gt;
   put 'Set objWorkbook  = objExcel.Workbooks.Open(workbook1)';&lt;BR /&gt;
&lt;BR /&gt;
   put 'objWorkbook.SaveAs workbook2,,pw';&lt;BR /&gt;
   put 'objExcel.Quit';&lt;BR /&gt;
&lt;BR /&gt;
   /* close the script file by opening another file */&lt;BR /&gt;
   filevar = catx('\',pathname('WORK'),'DUMMY2.vbs');&lt;BR /&gt;
   file dummy1 filevar=filevar;&lt;BR /&gt;
&lt;BR /&gt;
   /* look at the script, not necessary but may be useful */&lt;BR /&gt;
   infile dummy3 filevar=script end=eof;&lt;BR /&gt;
   do _n_ = 1 by 1 until(eof);&lt;BR /&gt;
      input;&lt;BR /&gt;
      putlog 'NOTE: ' _n_ 3. +1 _infile_;&lt;BR /&gt;
      end;&lt;BR /&gt;
&lt;BR /&gt;
   /* call the script */&lt;BR /&gt;
   command = catx(' ','cscript',quote(strip(script)));&lt;BR /&gt;
   infile dummy4 pipe filevar=command end=eof;&lt;BR /&gt;
   do until(eof);&lt;BR /&gt;
      input ;&lt;BR /&gt;
      putlog _infile_;&lt;BR /&gt;
      end;&lt;BR /&gt;
   stop;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 03 Sep 2009 13:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Set-password-for-excel/m-p/69169#M7952</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-09-03T13:23:08Z</dc:date>
    </item>
  </channel>
</rss>

