+ Reply to Thread
Results 1 to 2 of 2

How to set ToggleButton state from VBA code?

  1. #1
    Registered User
    Join Date
    02-18-2019
    Location
    Austin, TX
    MS-Off Ver
    Office 365
    Posts
    26

    How to set ToggleButton state from VBA code?

    Hello,

    I have a Ribbon with some toggle buttons on it. There's a custom UI xml where the buttons are defined, with 'getPressed' and 'onAction' callbacks defined. Also, this particular button is enclosed with another one in a 'group' in the xml.

    When the user presses one of these, occasionally I want to cancel the press, so I want to set the pressed state back to false. How can I do this?
    My onAction Sub looks like this - it takes an IRibbonControl as an argument:

    Please Login or Register  to view this content.
    Online I found reference to just setting the 'Value' of the control to false, but that gives me an error. I thought the problem might be that the argument needs to be a ToggleButton instead of an IRibbonControl. I tried adding a 'ToggleButton' variable and then setting that variable to argument 'oControl', but I got a 'user-defined type not defined' error, like it didn't know what a ToggleButton was. But 'ToggleButton' is a system type, isn't it? Why isn't it recognized?

    Anyone know how I can set this toggle button value from a Sub?

    Thanks!
    Last edited by bsabiston; 02-21-2019 at 01:24 PM.

  2. #2
    Registered User
    Join Date
    02-18-2019
    Location
    Austin, TX
    MS-Off Ver
    Office 365
    Posts
    26

    Re: How to set ToggleButton state from VBA code?

    Ok I figured this out - the 'pressed' state is actually modifiable just by changing the ByRef argument, in this case 'bPressed'. I set that to False. Also, I had to call Invalidate on the control via the ribbon ID, like this:

    goRibbon.InvalidateControl ("ButtonMoveRows")

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help with ToggleButton VBA code to hide/show specific worksheets
    By aprilnparker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-14-2018, 03:04 PM
  2. [SOLVED] City & State from Zip Code
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-24-2017, 02:51 PM
  3. 50 States, Drop-Down List, select a state then produce the # for that state
    By Sir CHARLES in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-30-2015, 07:46 PM
  4. [SOLVED] Lookup State Name from State Code and and Display in column in COUNTIES worksheet.
    By Jim15 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-11-2014, 02:41 PM
  5. Separate Zip Code from City, State Zip Code
    By caunyd in forum Excel General
    Replies: 3
    Last Post: 08-04-2013, 05:14 PM
  6. [SOLVED] VBA - Determining state from zip code
    By crayhons in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-11-2013, 04:45 PM
  7. Breaking Out State Code
    By NFJim in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-20-2009, 12:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1