ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Control button display issue (https://www.excelbanter.com/excel-programming/414578-control-button-display-issue.html)

Mike[_123_]

Control button display issue
 
I am adding buttons with the following code. They are active and
function but do not display. If I set them manually to "Text Only
(Always)" via the customize menu screen, they display fine. I'm using
XL2003.

I am at my wit's end trying to do this programmatically. What am I
missing? Thanks.

.Controls.Add Type:=msoControlButton, ID:=2949, Befo=2
With .Controls(1)
.Visible = True
.Caption = "ReadFile"
.OnAction = "thisworkbook.readfile"
End With

[email protected]

Control button display issue
 
On Jul 24, 6:38*pm, Mike wrote:
I am adding buttons with the following code. They are active and
function but do not display. If I set them manually to "Text Only
(Always)" *via the customize menu screen, they display fine. I'm using
XL2003.

I am at my wit's end trying to do this programmatically. What am I
missing? Thanks.

* * * * .Controls.Add Type:=msoControlButton, ID:=2949, Befo=2
* * * * With .Controls(1)
* * * * * * * * .Visible = True
* * * * * * * * .Caption = "ReadFile"
* * * * * * * * .OnAction = "thisworkbook.readfile"
* * * * End With


I don't get why you want to create buttons through code...

Try something like

Private Sub UserForm_Activate()
UserForm1.Commandbutton2.Visible = False
End Sub

Private Sub CommandButton1_Click()
If UserForm1.Commandbutton2.Visible = False Then
UserForm1.CommandButton2.Visible = True
End If

If UserForm1.Commandbutton2.Visible = True Then
UserForm1.CommandButton2.Visible = False
End If

End Sub

Hope that helps -- I've built a lot of complex programs and have never
had the need to have code create buttons... Your best bet is going
through .visible =

news.microsoft.com[_13_]

Control button display issue
 
After your response, I realized that I forgot to mention a crucial detail:
The buttons are toolbar buttons.




Mike[_123_]

Control button display issue
 
Solution was to add the following to each control button.

..Style = msoButtonCaption




All times are GMT +1. The time now is 05:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com