Kako prikazati slike iz različnih poti datotek v Excelu?
Če imate seznam poti do slikovnih datotek, želite zdaj prikazati ustrezne slike v sosednjem stolpcu na podlagi poti datotek, da dobite naslednji rezultat zaslona. Kako bi lahko to nalogo v Excelu rešili hitro in enostavno?
Tu vam lahko predstavim kodo VBA, ki vam bo pomagala. Naredite to:
1. Držite tipko ALT + F11 tipke za odpiranje Microsoft Visual Basic za aplikacije okno.
2. Kliknite Vstavi > Moduliin prilepite naslednjo kodo v Moduli Okno.
Koda VBA: Prikaži slike iz različnih poti datotek:
Sub InsertPicFromFile() Dim xRg As Range Dim xCell As Range Dim xVal As String On Error Resume Next Set xRg = Application.InputBox("Please select file path cells:", "KuTools for Excel", Selection.Address, , , , , 8) If xRg Is Nothing Then Exit Sub Application.ScreenUpdating = False For Each xCell In xRg xVal = xCell.Value If xVal <> "" Then ActiveSheet.Shapes.AddPicture xCell.Value, msoFalse, msoTrue, _ xCell.Offset(0, 1).Left, xCell.Top, xCell.Height, _ xCell.Height End If Next Application.ScreenUpdating = True End Sub
3. After inserting the above code, please press F5 key to run this code, and a prompt box is popped out to remind you select the cells of the file path, see screenshot:
4. Then click OK button, all images based on corresponding file paths have been displayed into next column as following screenshot shown:
If you are troubled with the above code, Kutools for Excel supports a handy feature - Insert Pictures from Path(URL), with this powerful utility, you can quickly insert the images based on file pathes or Url addresses at once.
After installing Kutools for Excel, please do as this:
1. Click Kutools > Insert > Insert Pictures from Path(URL), see screenshot:
2. In the Insert Pictures from Path(URL) dialog box, please do the following operations:
- Select the list of cells which contain the file path and a cell where you want to put the image;
- Then, specify the size of the picture that you want to use under the Picture Size section.
3. Then, click Ok button, the corresponding images have been inserted into the cells, see screenshot:
More relative articles:
- Convert Image URLs To Actual Images In Excel
- If you have a list of image URL addresses in column A, and now, you want to download the corresponding pictures from the URLs and display them into the adjacent column B as left screenshot shown. In Excel, how could you extract the actual pictures from the image URLs quickly and easily?
- Extract Hyperlinks From Multiple Images In Excel
- Let’s say, you have a list of images in a worksheet, and each image contains a hyperlink, now, you would like to extract the real hyperlink addresses from these pictures to their next cells as following screenshot shown. Of course, you can copy the hyperlink address from the Edit Hyperlink box one by one, but, this will be time-consuming if there are multiple hyperlinks needed to be extracted.
- Create Drop Down List With Images In Excel
- In Excel, we can quickly and easily create a drop down list with cell values, but, have you ever tried to create a drop down list with images, that is to say, when you click one value from the drop down list, its relative image will be displayed at the same time.
- Insert The Same Image Into Multiple Worksheets
- Normally, we can insert a picture into a worksheet quickly by using the Insert function in Excel, but, have ever tried to insert the same picture into all worksheets of your workbook?