excel 2003 running xp
Got a userform that is activated from a command button that fades out the background so the userform really stands out.
I have about 5 more command buttons on same page but can NOT get them to use the fade routine when their command buttons are pressed.
kind of got it to work with Buttons but thats not what they require, prefer to use command buttons.
' worked with buttons
Then repeated this for each ButtonSelect Case Application.Caller Case "Button 32" 'calls routine show picture which calls userform2 Call ShowFirstAid
Im guessing I need some kind of Class module to see which command button is pressed but stuck
added example file to look at, any help would be great.
Last edited by romperstomper; 07-21-2011 at 07:55 AM.
Can I ask why you want to use Commandbuttons rather than the more stable Forms buttons?
Because these command buttons are constant throughout the entire project, and you cant apply colour to form buttons.
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
You could just add a public commandbutton variable to the userform's module and set that in the button_click before you show the form.
The code for the fade is all in the example spreadsheet to download.
Can you colour the buttons in excel 2003 ?
Romperstomper can you give a coded example as not up to speed as still learning VB
code change to command buttons
Add this to the top of the Userform1 code module, along this the other declarations.Private Sub CommandButton6_Click() ScreenUpdating = False ShowDialog "FireSafety" End Sub Private Sub CommandButton7_Click() ScreenUpdating = False ShowDialog "FirstAid" End Sub
revise ShowPicture routinePublic ShowName As String
Sub ShowPicture() ' Displays on top of semi-transparent UserForm If Me.ShowName = "FirstAid" Then FirstAid.Show Else FireSafety.Show End If Unload Me End Sub
Add this to the declarations section in the userform:
and then refer to Button wherever you need it in the code.Public Button As MSForms.CommandButton
The ShowDialog code becomes:
and the button_click:Sub ShowDialog(btn As MSForms.CommandButton) Dim frm As UserForm1 Set frm = New UserForm1 Set frm.Button = btn frm.Show End Sub
Private Sub CommandButton7_Click() ScreenUpdating = False ShowDialog CommandButton7 End Sub
Romperstomper, Starting to look good but im losing the transparency behind the form ?
I missed out this change in Module15
Sub ShowDialog(Name As String) UserForm1.ShowName = Name UserForm1.Show End Sub
For mine, you need to alter the Userform_Activate code to use:
rather than:ufcap = Me.Caption
ufcap = Userform1.Caption
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks