Hi
I have a macro that is to run three macros in another file
Two of them run fine but the third I get an error on
This is the code for running the macros
Workbooks.Open Filename:=FileNameFolder & xlsmFile
Application.Run "'" & xlsmFile & "'!UpdateSummarySheet" 'woks fine
Application.Run "'" & xlsmFile & "'!CreateCostBreakdownSheet" 'works fine
Application.Run "'" & xlsmFile & "'!Remove" 'generates an error
This is the macro that I can't get to run from the other workbook
Is it the "Option Explicit" that is the problem?
Option Explicit
_______________________________________________________________________________________________
Public Sub Remove()
If MsgBox("Are you sure you want to delete the buttons?", vbOKCancel, "PCR Template") = vbCancel Then
Exit Sub
End If
Application.DisplayAlerts = False
Dim wb As Excel.Workbook
Set wb = ActiveWorkbook
Dim FileName As String
FileName = wb.Path & "" & Left(wb.Name, Len(wb.Name) - 5) & "_Cust.xlsm"
wb.SaveAs FileName
Dim ws As Excel.Worksheet
For Each ws In wb.Worksheets
wb.Sheets(ws.Name).Buttons.Delete
Next ws
Set ws = wb.Sheets("SupplierSheet")
ws.Visible = xlSheetHidden
Application.DisplayAlerts = True
End Sub
I have a macro that is to run three macros in another file
Two of them run fine but the third I get an error on
This is the code for running the macros
Workbooks.Open Filename:=FileNameFolder & xlsmFile
Application.Run "'" & xlsmFile & "'!UpdateSummarySheet" 'woks fine
Application.Run "'" & xlsmFile & "'!CreateCostBreakdownSheet" 'works fine
Application.Run "'" & xlsmFile & "'!Remove" 'generates an error
This is the macro that I can't get to run from the other workbook
Is it the "Option Explicit" that is the problem?
Option Explicit
_______________________________________________________________________________________________
Public Sub Remove()
If MsgBox("Are you sure you want to delete the buttons?", vbOKCancel, "PCR Template") = vbCancel Then
Exit Sub
End If
Application.DisplayAlerts = False
Dim wb As Excel.Workbook
Set wb = ActiveWorkbook
Dim FileName As String
FileName = wb.Path & "" & Left(wb.Name, Len(wb.Name) - 5) & "_Cust.xlsm"
wb.SaveAs FileName
Dim ws As Excel.Worksheet
For Each ws In wb.Worksheets
wb.Sheets(ws.Name).Buttons.Delete
Next ws
Set ws = wb.Sheets("SupplierSheet")
ws.Visible = xlSheetHidden
Application.DisplayAlerts = True
End Sub