Hoppa till huvudinnehåll

Hur konverterar man webbadresser till bilder till faktiska bilder i Excel?

doc url till bild 1

Om du har en lista med webbadresser till bilder i kolumn A och nu vill du ladda ner motsvarande bilder från webbadresserna och visa dem i intilliggande kolumn B som vänster skärmdump visas. Hur kunde du extrahera de faktiska bilderna från bild-URL: erna i Excel snabbt och enkelt?

Konvertera bild-URL: er till faktiska bilder med VBA-kod

Konvertera bild-URL: er till faktiska bilder med Kutools för Excel


Konvertera bild-URL: er till faktiska bilder med VBA-kod

Följande VBA-kod kan hjälpa dig att snabbt extrahera de faktiska bilderna från webbadresserna till bilden, gör så här:

1. Håll ner ALT + F11 för att öppna Microsoft Visual Basic for Applications-fönstret.

2. Klicka Insert > Modulernaoch klistra in följande kod i modulfönstret.

VBA-kod: Konvertera bild-URL: er till faktiska bilder:

Sub URLPictureInsert()
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
On Error Resume Next
Application.ScreenUpdating = False
Set Rng = ActiveSheet.Range("A2:A5")
For Each cell In Rng
filenam = cell
ActiveSheet.Pictures.Insert(filenam).Select
Set Pshp = Selection.ShapeRange.Item(1)
If Pshp Is Nothing Then GoTo lab
xCol = cell.Column + 1
Set xRg = Cells(cell.Row, xCol)
With Pshp
.LockAspectRatio = msoFalse
If .Width > xRg.Width Then .Width = xRg.Width * 2 / 3
If .Height > xRg.Height Then .Height = xRg.Height * 2 / 3
.Top = xRg.Top + (xRg.Height - .Height) / 2
.Left = xRg.Left + (xRg.Width - .Width) / 2
End With
lab:
Set Pshp = Nothing
Range("A2").Select
Next
Application.ScreenUpdating = True
End Sub

Anmärkningar: 

  • 1. I ovanstående kod, A2: A5 är cellintervallet som innehåller URL-adresserna du vill extrahera bilderna, bör du ändra cellreferenser efter dina behov.
  • 2. Med den här koden kan du inte ange storleken på de extraherade bilderna efter dina behov.
  • 3. Ovanstående kod kan endast extrahera de aktiva bilderna i cellerna förutom din URL-kolumn, du kan inte ange cell för att mata ut bilderna.
  • 4. Du bör ha en del grundläggande kunskaper om koden, om något tecken saknas eller är felaktigt kommer koden inte att köras framgångsrikt.

3. Tryck sedan på F5 nyckel för att köra den här koden och alla motsvarande bilder har extraherats från bild-URL: erna till den intilliggande kolumnen på en gång, och bilderna kommer att placeras i mitten av dina specifika celler, se skärmdump:

doc url till bild 2


Konvertera bild-URL: er till faktiska bilder med Kutools för Excel

Om du inte känner till VBA-koden eller vill åtgärda begränsningen av ovanstående kod, Kutools för Excel's Infoga bilder från sökväg (URL) funktionen kan hjälpa dig att snabbt infoga de motsvarande bilderna baserat på URL-adresserna eller den specifika sökvägen i din dator enligt nedanstående skärmdump. Klicka för att ladda ner Kutools för Excel!

Anmärkningar:Att tillämpa detta Infoga bilder från sökväg (URL)För det första bör du ladda ner Kutools för Excel, och använd sedan funktionen snabbt och enkelt.

När du har installerat Kutools för Excel, gör så här:

1. Klicka Kutools > Insert > Infoga bilder från sökväg (URL), i dialogrutan popped out, ställ in följande åtgärder, se skärmdumpar:

doc url till bild 3 doc url till bild 4

2. Klicka sedan Ok knappen, och bilderna extraheras från webbadresserna, se skärmdump:

doc url till bild 1

Klicka för att ladda ner och prova gratis Kutools för Excel nu!

Bästa kontorsproduktivitetsverktyg

🤖 Kutools AI Aide: Revolutionera dataanalys baserat på: Intelligent utförande   |  Generera kod  |  Skapa anpassade formler  |  Analysera data och generera diagram  |  Anropa Kutools funktioner.
Populära funktioner: Hitta, markera eller identifiera dubbletter   |  Ta bort tomma rader   |  Kombinera kolumner eller celler utan att förlora data   |   Rund utan formel ...
Superuppslag: Flera kriterier VLookup    VLookup med flera värden  |   VSök över flera ark   |   Fuzzy Lookup ....
Avancerad rullgardinslista: Skapa snabbt en rullgardinslista   |  Beroende rullgardinslista   |  Flervals-rullgardinslista ....
Kolumnhanterare: Lägg till ett specifikt antal kolumner  |  Flytta kolumner  |  Växla synlighetsstatus för dolda kolumner  |  Jämför intervall och kolumner ...
Utvalda funktioner: Rutnätsfokus   |  Designvy   |   Stor formelbar    Arbetsbok & Bladhanterare   |  Resursbibliotek (Automatisk text)   |  Datumväljare   |  Kombinera arbetsblad   |  Kryptera/Dekryptera celler    Skicka e-postmeddelanden efter lista   |  Superfilter   |   Specialfilter (filtrera fet/kursiv/genomstruken...) ...
Topp 15 verktygssatser12 text verktyg (lägga till text, Ta bort tecken, ...)   |   50+ Diagram Typer (Gantt Chart, ...)   |   40+ Praktiskt Formler (Beräkna ålder baserat på födelsedag, ...)   |   19 Införande verktyg (Infoga QR-kod, Infoga bild från sökväg, ...)   |   12 Konvertering verktyg (Siffror till ord, Valutaväxling, ...)   |   7 Slå ihop och dela verktyg (Avancerade kombinera rader, Dela celler, ...)   |   ... och mer

Uppgradera dina Excel-färdigheter med Kutools för Excel och upplev effektivitet som aldrig förr. Kutools för Excel erbjuder över 300 avancerade funktioner för att öka produktiviteten och spara tid.  Klicka här för att få den funktion du behöver mest...

Beskrivning


Fliken Office ger ett flikgränssnitt till Office och gör ditt arbete mycket enklare

  • Aktivera flikredigering och läsning i Word, Excel, PowerPoint, Publisher, Access, Visio och Project.
  • Öppna och skapa flera dokument i nya flikar i samma fönster, snarare än i nya fönster.
  • Ökar din produktivitet med 50 % och minskar hundratals musklick för dig varje dag!
Comments (61)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
can anyone help to extract mutiple links folllowed by comma  in one cell 
This comment was minimized by the moderator on the site
I own Kutools and I cannot seem to get this function to work properly. After I run it based on the examples above I get a message that says "1 picture(s) failed to be inserted"
Its not an htpps address. And the link the works fine when clicking from excel.
Please help
This comment was minimized by the moderator on the site
I have the same problem now. It worked very well yesterday, but today it's just not working :(
This comment was minimized by the moderator on the site
If I want the image to resize with the cell, is it as simple as changing this line to "msoTrue"?.LockAspectRatio = msoFalse


This comment was minimized by the moderator on the site
When I renew it takes the same picture again
So it adds images on top of each other
how can i prevent this?
Do not add the added picture again ?how can I do?
edit: also pictures are not loading when we open later?
This comment was minimized by the moderator on the site
When I renew it takes the same picture againSo it adds images on top of each other
how can i prevent this?
Do not add the added picture again ?how can I do?
This comment was minimized by the moderator on the site
thank you for VBA code, i able to get the url images as picture
but, after file closed, and then i opened it again, picture missing.
how to solve this problem?
This comment was minimized by the moderator on the site
Hello, Robby,After copying and pasting the code, when you close the workbook, you should save the file as Excel Macro-Enabled Workbook format for saving the code.When reopen the workbook, you should click the Enable Content button from the yellow ribbon at the top of the workbook.Please try, thank you!
This comment was minimized by the moderator on the site
thank you for fast response
I have save as Excel Enable Workbook and also Enable Content, and Picture will be shown up if i connected to internet, but when offline mode, the picture will be missing, Excel message : Picture can't be display
is there any solution so the picture will still shown up even though i am in offline mode (no internet available)
This comment was minimized by the moderator on the site
Hi, Robby, In this case, if you are in offline mode, I recommend you to use the Insert Pictures form Path(URL) feature of Kutools for Excel, you can download the Kutools and use it 30 days for free trail. After inserting the pictures, the pictures will be saved into the workbook.Please try.
This comment was minimized by the moderator on the site
What image types does this work with? I have mostly svg files and those are not working, but png and jpeg are fine.
This comment was minimized by the moderator on the site
Hello, travwoody,Yes, as you said, the code does not work for the svg files.Or can you insert a picture url here? We can test your image url for modifying the code.Thank you!
This comment was minimized by the moderator on the site
Why this line is not working for me?
Set Pshp = Selection.ShapeRange.Item(1)
Pshp object is becoming nothing, even though I have a valid image URL
This comment was minimized by the moderator on the site
I will also specify that I am writing about the VBA script
This comment was minimized by the moderator on the site
This code works great. Thank you!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations