Solved

vba excel RibbonX: Stepwise-access to controls  within a single group or tab

Posted on 2013-05-30
5
519 Views
Last Modified: 2013-05-30
This is a request for pointers toward solutions, so I can chase or ask about details.

I have a two stage process (StepA; StepB),  controlled respectively by Macros A and B. I'd like to run the macros from the Fluent ribbon, off two controls ButtonA and ButtonB, in the same Tab.

It is simple to have button A visible then the tab is active.
But I'd like button B ONLY to work (be visible/be enabled) when Button A has been clicked.

I control the Tab and ButtonA off getVisible and tag values
I have sought a means to control ButtonB off its control.ID, but there is no controls collection through which I might set ButtonB as visible (and hopefully render ButtonA invisible when step B is initiated). I dont need to collect 'pressed' data from the buttons

Can RibbonX buttons be controlled like this, or is there another 'dynamic' approach?

I have tried using a toggle button to deliver 'two stage' control. But was concerned that he user-driven processes that occur in step A, might somehow lift the focus from the toggle button before stepA was complete. Perhaps I should return to it..

... but finally, I've heard that windows task panes provide more dynamic properties and can replace dynamic userForms, and utilise their vba. Is this so?

PS I dont use visual studio..

Thanks, Kelvin
0
Comment
Question by:Kelvin4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 39208202
You will need a getVisible/getEnabled callback for the second button as well, and your first button will need to invalidate the second control (or the entire ribbon) in order for its callback to be called. In order to do that, you need an onLoad callback that stores a reference to the RibbonUI object.

Once you have that you could use a variable that macro A sets to True, then invalidates the control for B, whose callback simply checks the value of the variable set by A to see if button B should be enabled.

If you haven't already checked it out, Ron de Bruin's site has a lot of examples for the Ribbon: http://www.rondebruin.nl/win/s2/win001.htm
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 39208234
PS Here's a very simple example.
RibbonTest.xlsm
0
 

Author Comment

by:Kelvin4
ID: 39208327
Thanks.
I've been working from deBruin's files, and so have a reference to the RibbonUI object:

Sub RibbonOnLoad(ribbon As IRibbonUI)
    Set Rib = ribbon
End Sub

and use Rib.Invalidate:
Sub RefreshRibbon(Tag As String)
    MyTag = Tag
    If Rib Is Nothing Then
        MsgBox "Error, restart your workbook"
    Else
        Rib.Invalidate
    End If
End Sub

You refer to: " use a variable that macro A sets to True, then invalidates the control for B, whose callback simply checks the value of the variable set by A"

The only variables I have used with getVisible/getEnabled callbacks  are Tag values and control.Ids.  I dont know how to enable the callBack in B to check the boolean variable created by macroA?

Thanks..
0
 

Author Comment

by:Kelvin4
ID: 39208374
Thanks for example, looking..
0
 

Author Closing Comment

by:Kelvin4
ID: 39208422
rorya: EXCELLENT
Thanks for so rapidly showing me where the gap was!
Kelvin
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question