Programatically changing the picture on a command button

JONeill

Board Regular
Joined
Sep 2, 2018
Messages
58
Trying to toggle an image on a command button for sort direction. I keep getting a type mismatch.

currentPath = ActiveWorkook.Path
cmdSort.Picture = currentPath & "\sortAsc.gif"

Double checked the file name just to be sure.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Here is some code that might help.

Check out the LoadPicture to do the loading of the image on the CommandButton.

Private Sub CommandButton1_Click()
Dim picks
Static marker As Integer
picks = Array("c:\Documents\GH Up.jpg", "c:\Documents\GH Down.jpg")
Select Case marker
Case 0
marker = 1
Case 1
marker = 0
Case Else
marker = 0
End Select
CommandButton1.Picture = LoadPicture(picks(marker))
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top