kingcashandcarry
Member
i am trying to write a code but keeps failing
i have a wb called wb1 in folder z:\
i want a macro to open from wb1 wb2 call a macro save and close
then it will open wb3 call the same macro save and close and that is for 9 workbooks
the macro that i want to run is group sheets and save as pdf
[Sub GroupTabs()
Dim x As Integer
ThisWorkbook.Worksheets(1).Select
For x = 2 To ThisWorkbook.Worksheets.Count
Worksheets(x).Select (False)
Next x
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
"Z:\wb2.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
Sub AllFiles()
Dim folderPath As String
Dim filename As String
Dim wb As Workbook
folderPath = "Z:\" 'change to suit
If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
filename = Dir(folderPath & "*.xlsm")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath & filename)
'Call a subroutine here to operate on the just-opened workbook
Call GroupTabs
filename = Dir
Loop
Application.ScreenUpdating = True
End Sub]
that macro works for all files in the folder but in the folder there is the wb1
[Sub AllFiles()
Dim folderPath As String
Dim filename As String
Dim wb As Workbook
folderPath = "Z:\" 'change to suit
If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
filename = Dir(folderPath & "*.xlsm")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath & filename)
'Call a subroutine here to operate on the just-opened workbook
Call GroupTabs
filename = Dir
Loop
Application.ScreenUpdating = True
End Sub]
[
Workbooks("wb2.XLSm").Close SaveChanges:=true]
i have a wb called wb1 in folder z:\
i want a macro to open from wb1 wb2 call a macro save and close
then it will open wb3 call the same macro save and close and that is for 9 workbooks
the macro that i want to run is group sheets and save as pdf
[Sub GroupTabs()
Dim x As Integer
ThisWorkbook.Worksheets(1).Select
For x = 2 To ThisWorkbook.Worksheets.Count
Worksheets(x).Select (False)
Next x
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
"Z:\wb2.pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
Sub AllFiles()
Dim folderPath As String
Dim filename As String
Dim wb As Workbook
folderPath = "Z:\" 'change to suit
If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
filename = Dir(folderPath & "*.xlsm")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath & filename)
'Call a subroutine here to operate on the just-opened workbook
Call GroupTabs
filename = Dir
Loop
Application.ScreenUpdating = True
End Sub]
that macro works for all files in the folder but in the folder there is the wb1
[Sub AllFiles()
Dim folderPath As String
Dim filename As String
Dim wb As Workbook
folderPath = "Z:\" 'change to suit
If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
filename = Dir(folderPath & "*.xlsm")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath & filename)
'Call a subroutine here to operate on the just-opened workbook
Call GroupTabs
filename = Dir
Loop
Application.ScreenUpdating = True
End Sub]
[
Workbooks("wb2.XLSm").Close SaveChanges:=true]