Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
timmtamm
 
Posts: n/a
Default How do you print all worksheets in a file without opening the fil.

I have a folder with about 30 files in it which all have more than one
worksheet attached. Is is possible to print all the worksheets in all the
files from the folder?
Thanks
  #2   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Hi timmtamm

Try this for all files in the folder C:\Data
It will print the second sheet of each file.

Copy the code in a normal module in a workbook that is
not in the folder C:\Data.

Open a new workbook
Alt-F11
InsertModule from the menu bar
paste the sub in there
Alt-Q to go back to Excel

If you do Alt-F8 you get a list of your macro's
Select "TestFile1" and press Run


Sub TestFile1()
Dim basebook As Workbook
Dim mybook As Workbook
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir
MyPath = "C:\Data"
ChDrive MyPath
ChDir MyPath
FNames = Dir("*.xls")
If Len(FNames) = 0 Then
MsgBox "No files in the Directory"
ChDrive SaveDriveDir
ChDir SaveDriveDir
Exit Sub
End If

Application.ScreenUpdating = False
Do While FNames < ""
Set mybook = Workbooks.Open(FNames)
mybook.PrintOut
mybook.Close False
FNames = Dir()
Loop
ChDrive SaveDriveDir
ChDir SaveDriveDir
Application.ScreenUpdating = True
End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl



"timmtamm" wrote in message
...
I have a folder with about 30 files in it which all have more than one
worksheet attached. Is is possible to print all the worksheets in all the
files from the folder?
Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print all charts in a workbook (multiple worksheets) aewsaws Charts and Charting in Excel 4 May 12th 23 03:45 AM
Print several worksheets at once with fewer pages Stephen POWELL Excel Discussion (Misc queries) 6 January 25th 05 02:21 PM
Opening CSV file in Excel 97 Ron P Excel Discussion (Misc queries) 4 January 14th 05 10:41 PM
Add a default location for print to file in Excel. valders Excel Discussion (Misc queries) 0 December 30th 04 11:19 PM
Print Workbook Without Page Breaks Between Worksheets annem Excel Worksheet Functions 0 December 21st 04 08:05 PM


All times are GMT +1. The time now is 08:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"