Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print 1st worksheet of all workbooks in a folder 1

Status
Not open for further replies.

Wray69

Technical User
Oct 1, 2002
299
US
I need to print the first worksheet of every workbook on a network drive. I have gotten this far.

Private Sub PrintFiles()
Dim i As Long
Dim WB As Workbook
Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = "P:\MiniMonthlies\fairpoint"
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Set WB = Workbooks.Open(.FoundFiles(i))
WB.PrintOut Copies:=2
WB.Close False
Next i
End If
End With
Application.ScreenUpdating = True
End Sub

I can not figure out how to make it print just the first sheet, plus all the workbooks ask if you would like to update or not since they have external links. How can I set it to update all of them? Any help would be greatly appreciated.

Thanks,

Wray
 
Code:
...
Set WB = Workbooks.Open(.FoundFiles(i), True)
WB.Worksheets(1).PrintOut Copies:=2
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks, that took care of the update portion.

What do I need to do so that it only prints sheet 1?

Thanks again,

Wray
 
What do I need to do so that it only prints sheet 1
My suggestion was supposed to do that ...
WB[!].Worksheets(1)[/!].PrintOut Copies:=2

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
oops, missed that part... Little blind I think.

Thanks again,

Wray
 
OK, I guess I am not quite there.

The workbooks are located inside sub folders within "P:\MiniMonthlies\fairpoint\". How do I make it look for all workbooks under the main path? right now it is only printing the one workbook under the main path.
 
Replace this:
.SearchSubFolders = False
with this:
.SearchSubFolders = True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I am such a novice.

Thank You very much,

Wray
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top