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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

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