Even beyond what was thought
Microsoft Excel was not limited to create tables, write numbers and discover new formulas. Any new idea that the group of developers behind this program implements usually makes a big impact, including its mobile app launched on the Play Store.
In this way, the images became part of Microsoft Excel for give your files a different and dynamic touch, creating impressive creations such as order forms and catalogs.
Surely you thought that for this kind of thing you would need other programs. But the amazing thing about Microsoft Excel is that it allows you to create a catalog of images using the ActiveX Picture Control.
What is it about?
The goal of this is that, by selecting a certain cell, it comes the image inserted in that cell it should represent is displayed. That is, taking into account the existence of a database, a cell will represent a code or a product.
When you select the cell, it will represent that code within the image catalog. If you need some tips on building your database, you just need to be clear about the criteria because of this:
- Name of the products and their existence in stock.
- The images you will use in the catalog.
It is recommended that all images have the same format and that they are identified with the name of the codes that you will assign in the Excel workbook.
Creating the image control
To draw the picture control inside your Excel file, you need to go to the tab Developer, where you will find different sections, within which you will access:
- The option for to insert, clicking.
- The menu is divided between form controls and ActiveX controls.
- Within the second part of the menu, you will find the option to insert image control.
- After drawing it, click Property.
- Verify that the section AutoSize remain False.
- In the PictureAlignment you can select the way you want the image to appear: centered, left or right.
So you have to go to the option See code, this is right next to the section Designer mode, and will be used to access the VBA and establish the relevant codes to complete the configuration of this control.
- Click on the bar General and will change it to option Worksheet.
- The first part of creating the event should look like this:
Private Sub Worksheet_SelectionChange (ByVal Target As Range)
- Immediately after this event, you will write the following:
In case of an error Resume Next
- The above statement will make sure that, in case the process may have an error during the presentation of an image, it will not stop and cause VBA to debug. Rather, it simply skips the error line and moves on to the next one.
- Proceed to write the path as follows:
Image1.image = loadImage (
- Once the bracket is open, you will need to copy the path to the image. Click on address bar of File Explorer, copy and paste it into the box in quotes, then it should look like this:
Image1.picture = loadPicture (“C: Users user user Images BBDD ” & Target & ”. Jpg”)
- The instruction you are establishing with this code is that the image is displayed depending on what you have in the cell.
Minimize the VBA box, disable the designer mode and click on the codes you have established in your database. In this way, clicking on each cell with the codes, you will be shown the corresponding image.TagsEccellere