Programmatically determine if a control is .VISIBLE or not.

T

Toby Erkson

How does one determine if a control (button) on a command bar (toolbar) is visible or not so it can be acted upon for an IF...THEN statement?

This bit works if the control is visible:
Visible = Application.CommandBars("PivotTable").Controls("Refresh All").Visible

If the control is not visible then I get the following error:
Run-time error '5':
Invalid procedure call or argument

TIA!
Toby Erkson
Oregon, USA
 
T

Toby Erkson

Well, good to see that I can stump some people :)

Talked with a friend who's a VBA demi-god and here's what we got:
------------------------------------
....
Visible = isVisible("Refresh Data") 'Example of use
If Visible Then...
....

Function isVisible(sButton As String) As Boolean

On Error GoTo ErrorHandler
isVisible = Application.CommandBars("PivotTable").Controls(sButton).Visible
Exit Function

ErrorHandler:
isVisible = False
Exit Function
End Function
 
B

Bob Phillips

I am surprised no-one gave you a response to such a simple question, but
looking back at it I see your original post mentioned 'Refresh All'. That
may be why.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top