In Sheet(1) on the active.workbook where I play this VBA from (below), the sheet is named as "Log", starting on row 2 in the A column, is:
\\full path-networkpath+directory & workbook name to open.
As In:
\\network-drive\path\directory\test1.xls
\\network-drive\path\directory\test2.xls
In each of the workbooks to open: test1 and test2 [in this test], there is a module with a Sub named ADD_BUTTONS(), this VBA is supposed to open all the workbooks one-after another from A2 to last row and execute the ADD_BUTTONS code within its self and close, next... The ADD_BUTTONS has code to save the workbook operating on already after it does its thing, so there is no need for this script to change anything as far as Save.
So, it opens it, but the Module Sub don't seem to run, what am I doing wrong ?
That is the only part not working.
Thank you for the help!
Sub Open_WrkBks_Log_Run_ModuleSub_Within()
Dim wsLogName As String
Dim wsLog As Worksheet
Dim wsLogRange As Range
Dim FileToOpen As String
Dim RangeCell As Object
wsLogName = ActiveWorkbook.Name
Set wsLog = ActiveSheet
With wsLog
Sheets("Log").Activate
lastrow = .Range("A" & .Rows.Count).End(xlUp).Row
Set wsLogRange = Range("A2:A" & lastrow)
End With
For Each Value2 In wsLogRange.Cells
FileToOpen = Value2
On Error Resume Next
Workbooks.Open Filename:=FileToOpen
Application.Run (ADD_BUTTONS)
ActiveWorkbook.Close SaveChanges:=False
Next Value2
MsgBox "Finished Looping All workbooks from Log and running their Sub within"
End Sub
\\full path-networkpath+directory & workbook name to open.
As In:
\\network-drive\path\directory\test1.xls
\\network-drive\path\directory\test2.xls
In each of the workbooks to open: test1 and test2 [in this test], there is a module with a Sub named ADD_BUTTONS(), this VBA is supposed to open all the workbooks one-after another from A2 to last row and execute the ADD_BUTTONS code within its self and close, next... The ADD_BUTTONS has code to save the workbook operating on already after it does its thing, so there is no need for this script to change anything as far as Save.
So, it opens it, but the Module Sub don't seem to run, what am I doing wrong ?
That is the only part not working.
Thank you for the help!
Sub Open_WrkBks_Log_Run_ModuleSub_Within()
Dim wsLogName As String
Dim wsLog As Worksheet
Dim wsLogRange As Range
Dim FileToOpen As String
Dim RangeCell As Object
wsLogName = ActiveWorkbook.Name
Set wsLog = ActiveSheet
With wsLog
Sheets("Log").Activate
lastrow = .Range("A" & .Rows.Count).End(xlUp).Row
Set wsLogRange = Range("A2:A" & lastrow)
End With
For Each Value2 In wsLogRange.Cells
FileToOpen = Value2
On Error Resume Next
Workbooks.Open Filename:=FileToOpen
Application.Run (ADD_BUTTONS)
ActiveWorkbook.Close SaveChanges:=False
Next Value2
MsgBox "Finished Looping All workbooks from Log and running their Sub within"
End Sub