Copying image from Worksheet into UserForm at the click of a CommandButton

ZoraxD

New Member
Joined
Feb 25, 2016
Messages
2
Hi guys! Long time lurker first time poster here. Thank you so much for all the help you've been giving Excel n00bs such as myself so far. Has been very useful :)

My problem is in the title. After some googling, I've found a few methods, but need some further assistance.

1) The first method is Stephen Bullen's 'PastePicture' method. I've seen this cited a few times. The problem is that all the links to the file holding the code are dead. Infact, his entire website is down at the moment. I do not know if this is temporary or permanent; but either way, I cannot access the code for this method in order to study it. Does anyone have a copy of it saved, or know where I can find it? Or maybe remembers the logic and methods used?

2) The second method that I've come across is to upload all the images into the UserForm during initialization, and then just toggle their visibility on and off. This sounds extremely clunky, and I'm worried it may slow down the whole process. Would it actually slow down my program? And if not, is the code to do this relatively simple and easy to implement?

3) The third method is actually one from Ozgrid - Picture In Cell Into Image Control
Junho Lee posted this solution back in 2007, and I have downloaded the file and tried it out. It does actually work. However, I can't make heads or tails of the code itself. There are a lot of Privately Declared Functions and variables used that I do not understand. As such, I'm not quite sure how to take this code and use it within my existing project. I am studying it, but if anyone could go through it and explain the logic used for it, and perhaps highlight the key variables that I need to understand and alter to get the code to work in my project, I would greatly appreciate it!

Alternately, if anyone is aware of a different solution to what I've listed above, do please let me know :)

Some extra details on of my project that may or may not be useful:

- I use a UserForm to collect data from the user. There is text, two images, and some command buttons/drop down lists
- When they click the button to upload an image, they are prompted to select the file they want to upload from the computer. This basically is asking the user for the address of the file on the computer.
- After they've made their selection, the program then loads that image on to the UserForm AND two different worksheets (in the same workbook). All three lines of code us the same file address that the user selected. The images are loaded into the worksheets at specific addresses (determined earlier and stored in variables) and with specific sizes (determined earlier and stored in variables). One worksheet is called "Database" - this holds all the records the user has entered - and the other is called "Form" - this is basically a pretty-looking template which is used to save all the data entered into the UserForm as a PDF file.
- So far the uploading procedure works perfectly. Error checks and everything.
- What I am trying to add in now are two buttons - 'Previous' and 'Next' - to allow the User to cycle through all records stored in the Database sheet. Pretty standard I would imagine. So far that works well too - I get all the info read from the sheet and updated onto the UserForm, and the user is allowed to edit it. He can cycle back and forth. I got error conditions for when he's at the start or end of the Database. It all works perfectly.
- The only thing I'm stuck on are getting the images read from the sheet and moved into the UserForm.

And that's why I'm here. Any help appreciated. If you need anymore info, let me know :)

Thanks guys!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Problem is, you can't assign a picture object on a sheet directly to a userform. The userform requires a path/filename. (I find this rather annoying!) So, you have to export the object to a file, then load the picture into the userform.
 
Upvote 0
Problem is, you can't assign a picture object on a sheet directly to a userform. The userform requires a path/filename. (I find this rather annoying!) So, you have to export the object to a file, then load the picture into the userform.
Yea, thats what I feared.

The Ozgrid solution I linked to seem to make use of Windows API and the clipboard in order to copy the image and paste it into the UserForm. It works fine on the system I'm running, but I'm just stuck on understanding how it does that, and how I can modify/implement it to work in my code. The syntax is all new and confusing to me.

I haven't taken a look at it since I posted up this question, and since it's the weekend I understand if you're not keen on going through it now too, but whenever you do get the chance if you could help break down the syntax for me so I can better understand it I would really appreciate it.

Thanks :)
 
Upvote 0
but I'm just stuck on understanding how it does that,
I don't use API's that often and so have no answers for you other than to say, if you research each API, you might get answers to your questions.
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,513
Members
449,168
Latest member
CheerfulWalker

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