Is there any way to recover the bitmap image in a button?

Leon Lai
Lounger
Posts: 45
Joined: 12 Sep 2021, 14:50

Is there any way to recover the bitmap image in a button?

Post by Leon Lai »

Hello,

I have a UserForm with a few buttons.
Using PROPERTIES, I have attached a nice bitmap picture to each button (a long time ago).

I want to modify a picture, but I lost the source bitmap picture (.gif).

Where does the UserForm store the picture?

Is there a way I can retrieve the picture, so that I can modify it, and then reinsert it on the button?

Thanks
Leon Lai

SpeakEasy
StarLounger
Posts: 89
Joined: 27 Jun 2021, 10:46

Re: Is there any way to recover the bitmap image in a button?

Post by SpeakEasy »

SavePicture CommandButton1.Picture, "<folder_i_want_to_save_in>\buttonpic1.bmp"

Leon Lai
Lounger
Posts: 45
Joined: 12 Sep 2021, 14:50

Re: Is there any way to recover the bitmap image in a button?

Post by Leon Lai »

Hello SpeakEasy

Thanks for reply.
I don't quite understand what you are suggesting.

Could you please elaborate a little?

Is the picture found in a folder? Which path?

Leon

User avatar
HansV
Administrator
Posts: 72605
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Is there any way to recover the bitmap image in a button?

Post by HansV »

See the attached sample workbook. Clicking the button on the userform will save its picture to your Documents folder.

ExportGIF.xlsm
You do not have the required permissions to view the files attached to this post.
Regards,
Hans

Leon Lai
Lounger
Posts: 45
Joined: 12 Sep 2021, 14:50

Re: Is there any way to recover the bitmap image in a button?

Post by Leon Lai »

Hello Hans

That's great! It works.

Thanks a lot.
Leon

SpeakEasy
StarLounger
Posts: 89
Joined: 27 Jun 2021, 10:46

Re: Is there any way to recover the bitmap image in a button?

Post by SpeakEasy »

>Is the picture found in a folder? Which path?

No, for want of a better description that avoids the use of the oleobjectblob, it is stored in the button. The code I provided shows how to save the picture stored in a specific button to a named file in a folder as a bitmap

Hans' link does exactly the same thing. Despite giving the filename a gif extension, SavePicture still saves it as a bitmap, not a gif

User avatar
HansV
Administrator
Posts: 72605
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Is there any way to recover the bitmap image in a button?

Post by HansV »

My sample workbook was only meant as an illustration of your code, not as something new.
Regards,
Hans

SpeakEasy
StarLounger
Posts: 89
Joined: 27 Jun 2021, 10:46

Re: Is there any way to recover the bitmap image in a button?

Post by SpeakEasy »

No problem - I was really just clarifying that it does NOT result in a gif

User avatar
HansV
Administrator
Posts: 72605
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Is there any way to recover the bitmap image in a button?

Post by HansV »

Thanks for that, I didn't know that.
Regards,
Hans

Leon Lai
Lounger
Posts: 45
Joined: 12 Sep 2021, 14:50

Re: Is there any way to recover the bitmap image in a button?

Post by Leon Lai »

SpeakEasy wrote:
21 Oct 2021, 09:08
SavePicture CommandButton1.Picture, "<folder_i_want_to_save_in>\buttonpic1.bmp"
Hello SpeakEasy

Now, I understand your suggestion.

I tried your code in my button:
------
Private Sub CommandButton1_Click()
SavePicture Me.CommandButton1.Picture, "D:\TEST\myPic.bmp"
End Sub

-------

It works great!

Best Regards,
Leon