Hi there! Just a quick check. I put a Command Button in an Excel Sheet, "Monthly Report", in which it will copy this sheet along with another sheet, "Variables", and save it in a new workbook.
However, the Command Button will be copied as well. So is there anyway in VBA that I can delete the command button from the new workbook?
here are the codes from the Main workbook which have the command Button to generate that report
[vba]
Sub GenReport()
Dim DistiName As String
Dim filename As String
Dim MyMonth As Variant
Application.ScreenUpdating = False
MyMonth = Application.Proper(MonthName(Month(Date)))
Sheets("report").Activate
DistiName = Sheet23.Cells(5, 1)
Sheets(Array("Variables", "Report")).Copy
Sheets("Variables").Visible = xlVeryHidden
filename = ThisWorkbook.Path & "\" & DistiName & "-" & MyMonth & ".xls"
Application.CalculateFullRebuild
DeleteLinks_Selection
ActiveWorkbook.Sheets("Report").Range("A5").Validation.Delete
CommandButton1.Delete
ActiveWorkbook.SaveAs filename
Application.ScreenUpdating = True
End Sub
[/vba]
However when the code reach the line "commandbutton1.delete", they prompt me an error , "Run time '424' Object Required". Anybody willing to help?
regards
artds