(Solved) – How to change the picture in a userfrom if clicked

(solved)-–-how-to-change-the-picture-in-a-userfrom-if-clicked

I am trying to change a picture in a userform to an “active format” when it is clicked and then when another picture is clicked the picture that was previously clicked goes back to a “dormant format” and the new picture that has been clicked is now an “active format”. This is to show the user which menu they are currently on.

I have been trying to use the following code to do this but I cannot seem to get the pictures to return to the “dormant format” when the other picture is clicked. The code is also very lengthy so if there are an suggestions on how to reduce the length that would be helpful as I have 8 menus in the userform.

    '----------------------------------------------------------Menu 0 Button
Private Sub Home_Bttn_Click()

Home.MultiPage1.Value = 0

If Home.MultiPage1.Value = 0 Then

Home_Bttn.SpecialEffect = fmSpecialEffectRaised

'----------------------------------------------------------Changing button to active and setting others to Dormant
'Activated
Home_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsActivatedHome_Bttn_Activated.jpg")
'Dormant
Create_Protocol_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantCreate_Summary_Report_Bttn_Dormant.jpg")
Create_Summary_Report_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantCreate_Summary_Report_Bttn_Dormant.jpg")
Review_Summary_Report_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantReview_Summary_Report_Bttn_Dormant.jpg")
Add_Report_Template_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantAdd_Report_Template_Bttn_Dormant.jpg")
Add_Calbration_Certificates_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantAdd_Calbration_Certificates_Bttn_Dormant.jpg")
Add_to_Database_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantAdd_to_Database_Bttn_Dormant.jpg")
User_Agreement_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantUser_Agreement_Bttn_Dormant.jpg")
Email_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantEmail_Bttn_Dormant.jpg")
Mobile_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantMobile_Bttn_Dormant.jpg")
'Title
Menu_Title.Caption = "Home"

End If

End Sub

'----------------------------------------------------------Menu 1 Button
Private Sub Create_Protocol_Bttn_Click()

Home.MultiPage1.Value = 1

If Home.MultiPage1.Value = 1 Then

Create_Protocol_Bttn.SpecialEffect = fmSpecialEffectRaised

'----------------------------------------------------------Changing button to active and setting others to Dormant
'Activated
Create_Protocol_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsActivatedCreate_Protocol_Bttn_Activated.jpg")
'Dormant
Home_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantHome_Bttn_Dormant.jpg")
Create_Summary_Report_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantCreate_Summary_Report_Bttn_Dormant.jpg")
Review_Summary_Report_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantReview_Summary_Report_Bttn_Dormant.jpg")
Add_Report_Template_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantAdd_Report_Template_Bttn_Dormant.jpg")
Add_Calbration_Certificates_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantAdd_Calbration_Certificates_Bttn_Dormant.jpg")
Add_to_Database_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantAdd_to_Database_Bttn_Dormant.jpg")
User_Agreement_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantUser_Agreement_Bttn_Dormant.jpg")
Email_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantEmail_Bttn_Dormant.jpg")
Mobile_Bttn.Picture = LoadPicture(ThisWorkbook.Path & "UIGeneral ButtonsDormantMobile_Bttn_Dormant.jpg")
'Title
Menu_Title.Caption = "Create Protocol"

End If

End Sub

1 thought on “(Solved) – How to change the picture in a userfrom if clicked”

Leave a Reply

Your email address will not be published. Required fields are marked *