Hi,
I am trying to create a code that will allow me print all the sheets in several workbooks that is located in a similar directory folder. I started out with the following code, but I cannot get it to work.
Sub TempPrintMultWkbk()
Dim PathNm As String
PathNm = ActiveWorkbook.Path
Dim FSO, Fldr, Fle, Fls
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fldr = FSO.GetFolder(PathNm)
Set Fls = Fldr.Files
For Each Fle In Fls
If Right(Fle, 4) = ".xls" Then
Workbooks.Open Filename:=Fle
Workbooks(Fle).Activate
For Each sht In Sheets
sht.PrintOut
Next sht
Workbooks(Fle).Close savechanges:=False
End If
Next
End Sub
I keep runing into errors when I reach the section 'Workbooks(Fle).Activate'. I also have issues when the workbooks have links in them. Can someone provide a solution or a new code for me to use. Thanks for your help.
I am trying to create a code that will allow me print all the sheets in several workbooks that is located in a similar directory folder. I started out with the following code, but I cannot get it to work.
Sub TempPrintMultWkbk()
Dim PathNm As String
PathNm = ActiveWorkbook.Path
Dim FSO, Fldr, Fle, Fls
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Fldr = FSO.GetFolder(PathNm)
Set Fls = Fldr.Files
For Each Fle In Fls
If Right(Fle, 4) = ".xls" Then
Workbooks.Open Filename:=Fle
Workbooks(Fle).Activate
For Each sht In Sheets
sht.PrintOut
Next sht
Workbooks(Fle).Close savechanges:=False
End If
Next
End Sub
I keep runing into errors when I reach the section 'Workbooks(Fle).Activate'. I also have issues when the workbooks have links in them. Can someone provide a solution or a new code for me to use. Thanks for your help.