I have some buttons that run some code, each time I click the button, the VBE opens and I need it to not. I've tried Application.VBE.MainWindow.Visible = False
in several different locations (some not shown here), but it doesn't prevent anything.
Sub Clear_Sales_Button()
'
' Clear_Sales_Button Macro
'
Application.VBE.MainWindow.Visible = False
ActiveWorkbook.Sheets("Sales").Activate
ActiveSheet.Buttons.Add(44.25, 4.5, 144.75, 19.5).Select
Application.Goto Reference:="Clear_Sales_Button"
Selection.Characters.Text = "Clear Sales"
With Selection.Characters(Start:=1, Length:=11).Font
.Name = "Calibri"
.FontStyle = "Bold"
.Size = 12
.ColorIndex = 3
End With
Selection.OnAction = "Module1.Readd_Button"
Range("A1").Select
End Sub
Sub Readd_Button()
'
' Readd_Button Macro
'
' Keyboard Shortcut: Ctrl+w
'
Application.VBE.MainWindow.Visible = False
Application.ScreenUpdating = False
'Delete all cells
ActiveWorkbook.Sheets("Sales").Activate
ActiveSheet.Cells.Delete
'Add button back to Sales sheet
ActiveSheet.Buttons.Add(48, 15.75, 96, 29.25).Select
Application.Goto Reference:="Readd_Button"
Selection.Characters.Text = "Import Sales"
With Selection.Characters(Start:=1, Length:=12).Font
.Name = "Calibri"
.FontStyle = "Bold"
.Size = 12
.ColorIndex = 1
End With
Selection.OnAction = "Button1_Click"
Range("A1").Select
Application.ScreenUpdating = True
End Sub
I simply don't want the VBE to open, but cannot find a way to prevent it