Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Print all open files | Excel Programming | |||
importing tabs/sheets only from the currently open files | Excel Programming | |||
Print multiple files from File Open screen | Excel Programming | |||
Print/Open fdf/pdf files | Excel Programming | |||
Print/Open fdf/pdf files | Excel Programming |