Results 1 to 24 of 24

Thread: A simple problem, can't seem to find the solution

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Question A simple problem, can't seem to find the solution

    I'm trying to add a CommandBarComboBox to a custom command bar, and the command bar adds and populates fine, however i can't get it to fire its change event
    VB Code:
    1. 'cbrCmdBar is my command bar
    2. 'commandbareventclass handles all the command bar events
    3. Dim cBarCombo As CommandBarComboBox
    4. Set cBarCombo = cbrCmdBar.Controls.Add(msoControlDropdown)
    5. Set CommandBarEventClass.cBarBoxNavigation = cBarCombo
    6.  
    7. 'CommandBarEventClass code is below
    8.  
    9. Public WithEvents cBarBoxNavigation As CommandBarComboBox
    10.  
    11.  
    12. Public Sub cBarBoxNavigation_Change(ByVal Ctrl As Office.CommandBarComboBox)
    13.      msgBox "event fired"
    14. End Sub

    the event is not fired on teh change. I've used the same method to make command bar buttons and they work fine...so whats the deal with the combo box?? any help would be great, thanks

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: A simple problem, can't seem to find the solution

    the changed event only happens when you type something. If you are trying to find when the user selects another option, use the click event

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: A simple problem, can't seem to find the solution

    The CommandBarComboBox only has a change event, it is allegedly fired when someone makes a selection...alteast this is my understanding (and there is only 1 event selectable for it in visual studio)

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: A simple problem, can't seem to find the solution

    which program is this for?

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: A simple problem, can't seem to find the solution

    Microsoft Visio 2003

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: A simple problem, can't seem to find the solution

    Here is an MSDN example of exactly what i want to do, but the code simply doesn't work, the event does not get fired

    http://msdn.microsoft.com/library/de...HV05250825.asp

    frustrating...

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A simple problem, can't seem to find the solution

    Did you code in the .OnAction property for the combo box?
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  8. #8
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: A simple problem, can't seem to find the solution

    http://msdn.microsoft.com/library/de...HV05221091.asp

    is all i could find about clicking...hope it helps

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A simple problem, can't seem to find the solution

    There is only the Change event but it seems that the control is not linked to the event since there is no .OnAction property asigning the
    sub to the event. Depending on if this is an Add-In or Visio VBA you have the two syntaxes for 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  10. #10

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: A simple problem, can't seem to find the solution

    That example pertains to Control Buttons (msoControlButton). I am currently using those and they are working fine
    its the CommandBarComboBox that is giving me problem this problem

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A simple problem, can't seem to find the solution

    But if your not assinging your .OnAction then it wont fire.
    How does you code look like for adding the cbo?
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  12. #12

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: A simple problem, can't seem to find the solution

    it must be the .OnAction event...I don't have it implemented now, what should i set it as?

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A simple problem, can't seem to find the solution

    Depends. If you checkout the link smitty posted it shows the format. If its an add-in then "!<MyAddIn>" else if its Visio VBA
    then "MyEventSub".
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  14. #14

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: A simple problem, can't seem to find the solution

    Does the "MyEventSub" have to be in the same module as the place the command bar is created...if i want to you pass in paramteres can I pass in "MyEventSub(args)" ?

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A simple problem, can't seem to find the solution

    It should be in the class where you have the cbo withevents.
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  16. #16

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: A simple problem, can't seem to find the solution

    ok, i am not getting it to work
    this is my code in the setup class
    VB Code:
    1. Set cBarCombo = cbrCmdBar.Controls.Add(msoControlDropdown)
    2.     With cBarCombo
    3.         .Tag = "Navigate"
    4.         .Enabled = True
    5.         .OnAction = "cBarBoxNavigation_Change(cBarCombo)"
    6.     End With
    7.     PopulateNavigationBox cBarCombo
    8.     CommandBarEventClass.cBarBoxNavigation = cBarCombo
    it errors on the .OnAction line
    is this the wrong way/place to set this? i thought the chang event WAS the on action, it seems strange to me taht you would need to specify a sub if its a WithEvents object
    Last edited by Vhati; Jul 11th, 2005 at 01:28 PM. Reason: messed up

  17. #17
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: A simple problem, can't seem to find the solution

    whats the error?

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A simple problem, can't seem to find the solution

    Should be just...
    VB Code:
    1. .OnAction = "cBarBoxNavigation"
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  19. #19

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: A simple problem, can't seem to find the solution

    Ok, this is what i've been trying:
    I set up a method in my event handler class to sync the combo box, it looks like this
    VB Code:
    1. Public Sub SyncComboNav(box As Office.CommandBarComboBox)
    2.     Set cBarBoxNavigation = box
    3.     cBarBoxNavigation.OnAction = "cBarBoxNavigation_Change(cBarBoxNavigation)"
    4. End Sub
    this code: .OnAction = "cBarBoxNavigation"
    said the method "OnAction" failed
    however, this line
    .OnAction = "cBarBoxNavigation_Change(cBarBoxNavigation)"
    gave me an error saying "object required", which leads me to believe that
    it sort of worked, but the parameter cBarBoxNavigation didn't work because
    i've gotten that error before trying to use the combo box to get the text by doing
    VB Code:
    1. sMyText = cBarBoxNavigation.Text
    in an event fired from a command button (this way i could have a button that says "GO" and it would fire on the event and then check the text of the combo, but this didnt' work eiither)
    so i don't know what coudl be wrong still, or why it would say "object required' because the reference is not null
    Last edited by Vhati; Jul 11th, 2005 at 03:33 PM. Reason: another typo!

  20. #20
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A simple problem, can't seem to find the solution

    You need to post more of your code so we can see what is actually going on.
    You should not be setting the OnAction to the procedure name AND parameter.
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  21. #21

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: A simple problem, can't seem to find the solution

    Ok here is the full deal
    I have 2 class modules interacting here, one is to set up the command bar, the other is to handle the events. This is the code from the set up module:
    VB Code:
    1. Private cbrCmdBar As CommandBar
    2.  
    3. Private Sub SetupCommandBar()
    4.     Set cbrCmdBar = ovMyVisio.Application.CommandBars.Add(name:="Visual Mesa Navigation", Position:=msoBarTop, temporary:=True)
    5.  
    6.     cbrCmdBar.context = Str(visUIObjSetDrawing) & "*"
    7.     cbrCmdBar.Protection = msoBarNoMove + msoBarNoChangeDock + msoBarNoCustomize
    8.  
    9.     'I add a bunch of control buttons here, then the combo
    10.  
    11.     dim cBarCombo as CommandBarComboBox
    12.     Set cBarCombo = cbrCmdBar.Controls.Add(msoControlComboBox)
    13.     Set CommandBarEventClass.cBarBoxNavigation = cBarDrop
    14.  
    15. 'here ends my set up code, now for the event handling code
    16. Public WithEvents cBarBoxNavigation As Office.CommandBarComboBox
    17.  
    18. Private Sub cBarBoxNavigation_Change(ByVal Ctrl As Office.CommandBarComboBox)
    19.      MsgBox "Do something!"
    20. end sub
    Hope that helps some, the event is just not firing on the change

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: A simple problem, can't seem to find the solution

    Is there any reason that you need the events in a secondary class? It only complicates things and you may be running multiple
    instances of the combo so could be a possibility for not firing.
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  23. #23

    Thread Starter
    Member
    Join Date
    Jun 2005
    Location
    Portland, OR
    Posts
    47

    Re: A simple problem, can't seem to find the solution

    I tried it in that same class and it still didnt' work, i don'[t think that is the problem

  24. #24
    Lively Member
    Join Date
    Aug 2008
    Posts
    100

    Re: A simple problem, can't seem to find the solution

    Vhati did you ever get your combobox to work?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width