Re: [RESOLVED] Can't Get Menu Code to Run
another unsuccessful try... this sucks
vb Code:
Public myThing5 As Office.CommandBar
'Public temp As Office.CommandBarControls
Sub Workbook_BeforeClose(Cancel As Boolean)
myThing5.Delete
End Sub
Sub Workbook_Open()
On Error GoTo errHandler:
Set myThing5 = Application.CommandBars.Add("2245", msoBarPopup, , False)
UserForm1.Show vbModeless
errHandler:
myThing5.Delete
Set myThing5 = Application.CommandBars.Add("2245", msoBarPopup, , False)
UserForm1.Show vbModeless
End Sub
Re: [RESOLVED] Can't Get Menu Code to Run
only thing that is not working, is when I try to open IDE while my workbook is open.. When that happens and I try to reopen my userForm... it crashes
Re: [RESOLVED] Can't Get Menu Code to Run
Try this code as it doesnt error at all for me either with opening the IDE or not.
vb Code:
Option Explicit
Public myThing5 As Office.CommandBar
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If TypeName(myThing5) <> "Nothing" Then
myThing5.Delete
End If
End Sub
Private Sub Workbook_Open()
On Error GoTo errHandler
Set myThing5 = Application.CommandBars.Add("2245", msoBarPopup, , False)
UserForm1.Show vbModeless
Exit Sub
errHandler:
If TypeName(myThing5) = "Nothing" Then
Set myThing5 = Application.CommandBars.Item("2245")
Else
MsgBox "Unexpected Error"
End If
If UserForm1.Visible = False Then
UserForm1.Show vbModeless
End If
End Sub
Re: [RESOLVED] Can't Get Menu Code to Run
Great... Actually arrived at a similar piece of code through some error handling as well, but yours works fine too..
thanks for all the help, I appreciate it much!