Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
nc nc is offline
external usenet poster
 
Posts: 119
Default Printing the same range in a workbook

How can I use macro to print the same range for all the workbooks in a
specific folder.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Printing the same range in a workbook

nc,

Pick one, change the path and the print area range address:

Sub PrintOneSheetFromAllFilesInFolder()
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Excel"
.FileType = msoFileTypeExcelWorkbooks
If .Execute 0 Then
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
ActiveSheet.PageSetup.PrintArea = "$A$1:$D$12"
ActiveSheet.PrintOut
ActiveWorkbook.Close True
Next i
End If
End With
End Sub

Sub PrintAllSheetsFromAllFilesInFolder()
Dim mySht As Worksheet
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings\Excel"
.FileType = msoFileTypeExcelWorkbooks
If .Execute 0 Then
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
For Each mySht In ActiveWorkbook.Worksheets
mySht.PageSetup.PrintArea = "$A$1:$D$12"
mySht.PrintOut
Next mySht
ActiveWorkbook.Close True
Next i
End If
End With
End Sub

--
HTH,
Bernie
MS Excel MVP


"nc" wrote in message
...
How can I use macro to print the same range for all the workbooks in a
specific folder.

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Printing the same range in a workbook

Hi

You can try this macro for all files in the folder C:\Data
MyPath = "C:\Data"


It will print A1:C1 from the first sheet of every workbook

See this line
mybook.Worksheets(1).Range("A1:C1").PrintOut




Sub Example1()
Dim mybook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim rnum As Long
Dim SourceRcount As Long
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.Worksheets(1).Range("A1:C1").PrintOut

mybook.Close False
FNames = Dir()
Loop
ChDrive SaveDriveDir
ChDir SaveDriveDir
Application.ScreenUpdating = True
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"nc" wrote in message ...
How can I use macro to print the same range for all the workbooks in a
specific 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
Printing a workbook Teddybear New Users to Excel 1 January 5th 08 09:48 AM
Printing Workbook Jackie Osterman Excel Discussion (Misc queries) 1 January 5th 06 01:46 AM
Do something when workbook is printing Man Utd New Users to Excel 2 October 20th 05 02:31 AM
printing workbook Lisa Excel Discussion (Misc queries) 1 March 9th 05 02:31 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM


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