In the previous section, you learned how to create a simple User Form. You'll now learn how to create a more elaborate User Form. This form will have text and combo boxes, options buttons, tabs, and a picture box. This is quite a long project, but it will bring your Excel VBA programming skills on a treat. What you'll create is a picture viewer that looks like this:
The first tab pulls image information from a spreadsheet. The image associated with the information is also displayed.
Notice the button at top of the View Photos tab. It says Load Image Information. When this button is clicked the form changes to this:
Loading the image information activates the Previous Photo and Next Photo buttons. Clicking these buttons allows us to display other images.
The second tab on our picture viewer is for adding new image information to the spreadsheet. It looks like this:
Clicking the Add New Picture button displays an Open File dialogue box where we can select an image. This image will appear in the picture box on the form. The Save New Details button becomes active once an image is selected. The textboxes can then filled out before these new details are added to the spreadsheet.
Spreadsheet Image Information
Create a new blank spreadsheet for this project. All the image information for the picture viewer is coming from a spreadsheet. This spreadsheet:
Create the spreadsheet using the same information above.
Now that you have the data for the spreadsheet, save your work. But when you get to the Save As dialogue box, create a new folder. Call the new folder sheets. For the file name, type picture_viewer.xlsm. Before clicking the Save button, create another new folder and call it images. Your Save As dialogue box should look like this:
Now double click the sheets folder and save your picture_viewer.xlsm spreadsheet inside of this folder.
You now need some images. Right click an image link below and select Save Target As if you're using Internet Explorer (or Save Link As in Firefox and Chrome). Then navigate to your images folder and save them there.
london_eye.jpg st_peters.jpg nefertiti.jpg carpeaux.jpg
Now that you have everything you need, we'll make a start on the form design in the next lesson below.