Results 1 to 3 of 3

Thread: Creating a toolbar button through code?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    13

    Creating a toolbar button through code?

    I've tried using the macro recorder to get some hints on this one, but it doesn't seem to pick anything up...

    I'd like to create a button on a (custom) toolbar and set it to run a certain macro when a workbook is opened. I've got the code for creating the toolbar in place...

    My goal is to have a toolbar that allows the user to select between worksheets since the tabs at the bottom need to be scrolled and right clicking on the scroll buttons only brings up a partial list until the user clicks on the entry to bring up the entire list.

    I see some other directions I'd like to go from here (having subfields, much like you can organize your bookmarks and start menus) but first off I'd like to have a solution where the controls do not move off the screen when the page is scrolled.

    I've looked at using freeze panes but that method just looks messy compared to putting a toolbar up...

    Thanks all,

    David.

  2. #2

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    13

    Re: Creating a toolbar button through code?

    Looking at the Application.CommandBars("TheCommandBarICreated") object in the debugger a little more closely, I'm thinking I may find my solution with the .Controls.Item1.OnAction property.

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

    Re: Creating a toolbar button through code?

    If you want to run a commandbar button, either menu or toolbar, just run the .Execute method of the commandbarbutton object instance.
    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

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