Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Printing worksheets in excel spreadsheet

i have approx 45 spreadsheets in a directory (directory is
"c:\SCRIPTS".

Each spreadsheet has 3 worksheets.

Is there a simple macro (VBA) which can open up each workbook in turn
and then print the entire workbook and then close spreasheet and go on
to next one.


I presume gthe VBA is something along the lines of

1) Read the names of *.xls files in directory "c:\SCRIPTS" and store
this info

2) Open the file

3) Then
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
This will print all worksheets

4) Then
ActiveWindow.Close
to close workbook

5) Go back to (2) and open next file

Can anyone help me with the code for (1), (2) and (5)

Regards

Steve Fisher
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Printing worksheets in excel spreadsheet

Hi Steve

Try this to print all the workboooks in C:\SCRIPTS

Sub Test()
Dim mybook As Workbook
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir
MyPath = "C:\SCRIPTS"
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
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Steve Fisher" wrote in message m...
i have approx 45 spreadsheets in a directory (directory is
"c:\SCRIPTS".

Each spreadsheet has 3 worksheets.

Is there a simple macro (VBA) which can open up each workbook in turn
and then print the entire workbook and then close spreasheet and go on
to next one.


I presume gthe VBA is something along the lines of

1) Read the names of *.xls files in directory "c:\SCRIPTS" and store
this info

2) Open the file

3) Then
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
This will print all worksheets

4) Then
ActiveWindow.Close
to close workbook

5) Go back to (2) and open next file

Can anyone help me with the code for (1), (2) and (5)

Regards

Steve Fisher



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Printing worksheets in excel spreadsheet

Hi Steve:

You should be able to work it out from this Tom Ogilvy post:

http://google.com/groups?threadm=8fj...ndspr ing.net

Regards,

Vasant.

"Steve Fisher" wrote in message
m...
i have approx 45 spreadsheets in a directory (directory is
"c:\SCRIPTS".

Each spreadsheet has 3 worksheets.

Is there a simple macro (VBA) which can open up each workbook in turn
and then print the entire workbook and then close spreasheet and go on
to next one.


I presume gthe VBA is something along the lines of

1) Read the names of *.xls files in directory "c:\SCRIPTS" and store
this info

2) Open the file

3) Then
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
This will print all worksheets

4) Then
ActiveWindow.Close
to close workbook

5) Go back to (2) and open next file

Can anyone help me with the code for (1), (2) and (5)

Regards

Steve Fisher



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
Printing an Excel Spreadsheet memartha Excel Discussion (Misc queries) 1 January 14th 10 12:27 AM
Printing Excel Worksheets Justme 61 Excel Discussion (Misc queries) 1 April 4th 08 10:07 PM
Printing Filtered Excel Worksheets widman Excel Discussion (Misc queries) 0 November 29th 06 03:58 PM
Duplex printing an Excel Spreadsheet Matilda Excel Discussion (Misc queries) 0 September 26th 06 04:11 PM
printing worksheets in Excel BGA Excel Discussion (Misc queries) 1 February 17th 05 03:24 PM


All times are GMT +1. The time now is 03:01 AM.

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

About Us

"It's about Microsoft Excel"