Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can iterate through the workbooks in a folder using the <a href="http://www.devguru.com/technologies/vbscript/quickref/filesystemobject.html" rel="nofollow">FileSystemObject</a> by using the <a href="http://www.devguru.com/technologies/vbscript/quickref/folder.html" rel="nofollow">Folder</a> and <a href="http://www.devguru.com/technologies/vbscript/quickref/file.html" rel="nofollow">File</a> objects. (Remember to add a reference to the <code>Microsoft Scripting Runtime</code>)</p> <p>Iterating through worksheets is as easy as a <code>For Each</code> over the <code>Workbook.Sheets</code> collection.</p> <p>Finally, you can print the worksheet using the <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.printout%28v=vs.80%29.aspx" rel="nofollow">PrintOut</a> method on each worksheet to print them. Just make sure to set the <code>PrintToFile</code> parameter to true.</p> <p>If you need more direction than that, I suggest following @JMax's advice and post some of what you've tried already.</p> <p><strong>UPDATE</strong></p> <p>To iterate through workbooks using <code>FileSystemObject</code>:</p> <pre><code>Sub Make_PS_Files() Dim fso As New Scripting.FileSystemObject Dim source As Scripting.Folder Dim wbFile As Scripting.File Dim book As Excel.Workbook Set source = fso.GetFolder("Drive:\Source folder\") For Each wbFile In source.Files If fso.GetExtensionName(wbFile.Name) = "xls" Then Set book = Workbooks.Open(wbFile.Path) ' Print out the workbook End If Next End Sub </code></pre> <p>And to iterate through the worksheets in a workbook: </p> <pre><code>Dim sheet As Excel.Worksheet For Each sheet in book.Sheets sheet.PrintOut Copies:=1, ActivePrinter:="\\Printer:", PrintToFile:=True, _ PrToFileName:=fso.BuildPath(destination, sheet.Name &amp; ".ps") Next </code></pre> <p>Keep in mind that this has no error handling, but I hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload