|
-
Jun 11th, 2007, 04:09 PM
#41
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
are you saying this should work? in workbook_open
myThing5.Delete
Set myThing5 = Application.CommandBars.Add("paul3", msoBarPopup, , True)
UserForm1.Show vbModeless
-
Jun 11th, 2007, 04:39 PM
#42
Re: [RESOLVED] Can't Get Menu Code to Run
No.
What if its the first run of your workbook? The command bar will not exist so referencing it will generate an error.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 11th, 2007, 05:28 PM
#43
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
So something like
vb Code:
Set temp = CommandBars.FindControls(msoControlButton, , "paul6")
If temp.Count = 0 Then
Set myThing5 = Application.CommandBars.Add("paul6", msoBarPopup, , True)
ElseIf temp.Count > 0 Then
myThing5.Delete
Set myThing5 = Application.CommandBars.Add("paul6", msoBarPopup, , True)
End If
UserForm1.Show vbModeless
except that findControls method isn't working. Any help on using the findControls method? tried using MSDN but didn't help out too much.
-
Jun 11th, 2007, 06:15 PM
#44
Re: [RESOLVED] Can't Get Menu Code to Run
More like this...
Code:
Set temp = CommandBars.FindControls(msoControlButton, , "paul6")
If TypeName(temp) = "Nothing" Then
Set myThing5 = Application.CommandBars.Add("paul6", msoBarPopup, , True)
End If
UserForm1.Show vbModeless
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 12th, 2007, 10:01 AM
#45
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
Set temp = CommandBars.FindControls(msoControlButton, , "paul6") isn't working, and msdn is of no help.
-
Jun 12th, 2007, 10:53 AM
#46
Re: [RESOLVED] Can't Get Menu Code to Run
Why are you trying to look for a button when you are initially going to be looking for your commandbar?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 12th, 2007, 10:56 AM
#47
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
b/c button made the most sense out of these:
msoControlActiveX
msoControlAutoCompleteCombo
msoControlButton
msoControlButtonDropdown
msoControlButtonPopup
msoControlComboBox
msoControlCustom
msoControlDropdown
msoControlEdit
msoControlExpandingGrid
msoControlGauge
msoControlGenericDropdown
msoControlGraphicCombo
msoControlGraphicDropdown
msoControlGraphicPopup
msoControlGrid
msoControlLabel
msoControlLabelEx
msoControlOCXDropDown
msoControlPane
msoControlPopup
msoControlSpinner
msoControlSplitButtonMRUPopup
msoControlSplitButtonPopup
msoControlSplitDropdown
msoControlSplitExpandingGrid
msoControlWorkPane
-
Jun 12th, 2007, 11:02 AM
#48
Re: [RESOLVED] Can't Get Menu Code to Run
Well as you can see the findcontrol function takes arguments of -
FindControl([Type], [Id], [Tag], [Visible], [Recursive])
You can leave the control type blank but when you added your command bar did you just give it a name and search for it by that name.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 12th, 2007, 11:20 AM
#49
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
Well this isn't working either...
Code:
Public myThing5 As Office.CommandBar
Public temp As Office.CommandBarControls
Sub Workbook_BeforeClose(Cancel As Boolean)
myThing5.Delete
End Sub
Sub Workbook_Open()
Set temp = CommandBars.FindControls(, , "paul5512")
If TypeName(temp) = "Nothing" Then
Set myThing5 = Application.CommandBars.Add("paul5512", msoBarPopup, , True)
End If
UserForm1.Show vbModeless
End Sub
error "object var not set" on findcontrols line
-
Jun 12th, 2007, 11:27 AM
#50
Re: [RESOLVED] Can't Get Menu Code to Run
Not sure why this is so difficult but try this...
Set temp = CommandBars.Item("paul5512")
instead.
Are you looking for a button or a command bar?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 12th, 2007, 11:36 AM
#51
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
Yeah same error w/ that.
I'm looking for w/e myThing5 is... a commandBar, I think. Is my declaration of temp incorrect?
-
Jun 12th, 2007, 11:40 AM
#52
Re: [RESOLVED] Can't Get Menu Code to Run
Well if its temp then thats different then what you had it as a few posts ago. Please post your current code so we can work with it.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 12th, 2007, 11:42 AM
#53
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
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()
'Set temp = CommandBars.FindControls(, , "paul")
Set temp = CommandBars.Item("paul")
If TypeName(temp) = "Nothing" Then
Set myThing5 = Application.CommandBars.Add("paul", msoBarPopup, , True)
End If
UserForm1.Show vbModeless
End Sub
-
Jun 12th, 2007, 11:50 AM
#54
Re: [RESOLVED] Can't Get Menu Code to Run
Ok its Temp so shouldnt be looking for it upon load then. Should be able to just add each time. Are you getting any errors with this code?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 12th, 2007, 11:54 AM
#55
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
Well I have to check if it's been created b/c of that strange thing that happens when IDE is opened.
and the above code doesn't work, as
Set temp = CommbandBars.Item("paul") gets error 91
-
Jun 12th, 2007, 12:22 PM
#56
Re: [RESOLVED] Can't Get Menu Code to Run
Add error handling for that part.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 12th, 2007, 12:27 PM
#57
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
I don't think error handling is the answer. I need to find if this commandbar exists already, and need a method that works. I have no working method, so error would always be thrown.
-
Jun 12th, 2007, 12:34 PM
#58
Re: [RESOLVED] Can't Get Menu Code to Run
That is what error handling is for. 
If it errors then you know it exists when .Add or Set. Then you can resume next and continue on. If it doesnt exist then it will be all good.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 12th, 2007, 12:46 PM
#59
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
Tried this out.. Works until IDE is opened.. Then when going back to open the form crashes again.
Public myThing5 As Office.CommandBar
'Public temp As Office.CommandBarControls
Sub Workbook_BeforeClose(Cancel As Boolean)
myThing5.Delete
End Sub
Sub Workbook_Open()
'Set temp = CommandBars.FindControls(, , "paul")
'On Error Resume Next
'Set temp = CommandBars.Item("paull")
'If TypeName(temp) = "Nothing" Then
' Set myThing5 = Application.CommandBars.Add("paull", msoBarPopup, , True)
'End If
'UserForm1.Show vbModeless
'On Error GoTo 0
On Error GoTo errHandler:
Set myThing5 = Application.CommandBars.Add("23", msoBarPopup, , True)
UserForm1.Show vbModeless
errHandler:
UserForm1.Show vbModeless
Resume Next
End Sub
-
Jun 12th, 2007, 12:47 PM
#60
Thread Starter
Hyperactive Member
Re: [RESOLVED] Can't Get Menu Code to Run
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()
'Set temp = CommandBars.FindControls(, , "paul")
'On Error Resume Next
'Set temp = CommandBars.Item("paull")
'If TypeName(temp) = "Nothing" Then
' Set myThing5 = Application.CommandBars.Add("paull", msoBarPopup, , True)
'End If
'UserForm1.Show vbModeless
'On Error GoTo 0
On Error GoTo errHandler:
Set myThing5 = Application.CommandBars.Add("23", msoBarPopup, , True)
UserForm1.Show vbModeless
errHandler:
UserForm1.Show vbModeless
Resume Next
End Sub
-
Jun 12th, 2007, 12:54 PM
#61
Thread Starter
Hyperactive Member
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
-
Jun 12th, 2007, 12:54 PM
#62
Thread Starter
Hyperactive Member
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
-
Jun 12th, 2007, 10:47 PM
#63
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 13th, 2007, 10:05 AM
#64
Thread Starter
Hyperactive Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|