can add icons as buttons without add commandbutton on userform

MKLAQ

Active Member
Joined
Jan 30, 2021
Messages
419
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I'm not sure what I ask maybe could in excel.
as known when add icon into commandbutton on form will not show the caption clearly after upload icon . I have to resize the button then will be much big to show caption. my goal I will design the button by PHOTHOSHOP and I will upload to excel.
my question is: can I add the icon as picture on form without add commandbutton like inside sheet will use some shapes (rectangular, oval) and link it with macro?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
You could add an image control and use that, but you can't add shapes.
 
Upvote 0
You could add an image control and use that
but how add png image to commandbutton
I have the code about png but shows error when link with commandbutton1
like this
VBA Code:
Private Sub UserForm_Activate()
Dim vntFilename As Variant
    
    vntFilename = Application.GetOpenFilename("Images (*.png),*.png")
    If vntFilename = "False" Then Exit Sub
    
    CommandButton1.Caption = LoadImage(vntFilename)
End Sub
 
Upvote 0
use the picture property not caption
 
Upvote 0
unfortunately doesn't show picture and doesn't show error!
VBA Code:
Private Sub UserForm_Activate()
Dim vntFilename As Variant
    
    vntFilename = Application.GetOpenFilename("Images (*.png),*.png")
    If vntFilename = "False" Then Exit Sub
    
    CommandButton1.Picture = LoadImage("C:\Users\MK\Pictures\qw.png")
End Sub
 
Upvote 0
I see label could use it so I suppose commandbutton should use it too.
but doesn't work
VBA Code:
Private Sub UserForm_Activate()
Dim vntFilename As Variant
    
    vntFilename = Application.GetOpenFilename("Images (*.png),*.png")
    If vntFilename = "False" Then Exit Sub
    
    Me.CommandButton1.Picture = LoadImage("C:\Users\MK\Pictures\qw.png,Me.CommandButton1")
End Sub
 
Upvote 0
Again, you cannot use a png format like that.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

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