IsaacAsher
New Member
- Joined
- Jul 25, 2007
- Messages
- 2
Greetings!
I found the following code on this same board and used it successfully a few times. I made a few edits to the original code as I just need to print the entire file as opposed to printing individual sheets as the code was first written.
My goal is to loop through all files in a the current folder, and print them if they are not called "REQUEST-PRINTER.xls" which is the name of the file where I placed this code.
As I said, this worked the first few times (after my edits, mind you). Today when I tried to run it, it said:
The error is occurring on Workbooks.Open oFile.Name
Not sure what happened here, as 85013615.xls is indeed the correct name of the first file that should be printed, and I did not make any edits to the code after my initial re-working.
Any ideas?
Most thankful,
Isaac
I found the following code on this same board and used it successfully a few times. I made a few edits to the original code as I just need to print the entire file as opposed to printing individual sheets as the code was first written.
My goal is to loop through all files in a the current folder, and print them if they are not called "REQUEST-PRINTER.xls" which is the name of the file where I placed this code.
Code:
Public Count
Sub Printer()
Dim fso As Object, oFolder As Object, oFile As Object
Dim path_name As String
path_name = ActiveWorkbook.Path
Application.DisplayAlerts = False
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder(path_name)
For Each oFile In oFolder.Files
If Left(oFile.Name, 7) <> "REQUEST" Then
Workbooks.Open oFile.Name
For x = 1 To Count
ActiveSheet.PrintOut
Next x
ActiveWorkbook.Close
End If
Next
End Sub
As I said, this worked the first few times (after my edits, mind you). Today when I tried to run it, it said:
Code:
Run-time error '1004':
'85013615.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct.
If you are trying to open the file from your list of most recently used files on the File menu, make sure that the file has not been renamed, moved, or deleted.
The error is occurring on Workbooks.Open oFile.Name
Not sure what happened here, as 85013615.xls is indeed the correct name of the first file that should be printed, and I did not make any edits to the code after my initial re-working.
Any ideas?
Most thankful,
Isaac