LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default Print only the used sheets in all open files

I have the below macro to print the sheets that have info in cells D6 or D3
for all open workbooks. "PrintAllOpenFiles.xlsm" is the file in the
xlstartup dir. If u run the small macro listed first within a single file it
works but inside the bigger macro it doesn't. It doesn't look like anything
happens - no debug option or anything. Any help is appreciated.

'Print Used Sheets
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.Visible = -1 Then
If sh.Range("D6").Value < "" Or sh.Range("D3").Value <
"" Then
sh.PrintPreview
'sh.PrintOut copies:=1
End If
End If
Next





Sub PrintAllOpenFiles()

Dim x As Workbook

' Loop through all open workbooks.
For Each x In Application.Workbooks

' You don't want to print this workbook.
If x.Name < "PrintAllOpenFiles.xlsm" Then

' Activate the workbook.
x.Activate

'Print the active worksheet in the current workbook.
'x.SelectedSheets.PrintOut copies:=1


'Print Used Sheets
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.Visible = -1 Then
If sh.Range("D6").Value < "" Or sh.Range("D3").Value <
"" Then
sh.PrintPreview
'sh.PrintOut copies:=1
End If
End If
Next

' Close the current workbook.
x.Close

'End If
Next x


'Remove the apostrophe from the next line of code if you
'want to exit Excel when this process has completed.
'Application.Quit

End Sub

 
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 open files Bill Excel Programming 0 April 26th 10 10:37 PM
importing tabs/sheets only from the currently open files stefano canepa Excel Programming 1 October 7th 09 01:48 PM
Print multiple files from File Open screen MarvInBoise Excel Programming 0 August 28th 07 02:26 PM
Print/Open fdf/pdf files [email protected] Excel Programming 1 January 26th 07 04:43 AM
Print/Open fdf/pdf files [email protected] Excel Programming 0 January 25th 07 05:04 PM


All times are GMT +1. The time now is 03:10 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"