Saltar al contenido principal

¿Cómo convertir URL de imágenes en imágenes reales en Excel?

Autor: Xiaoyang Última modificación: 2023-04-11
URL del documento a img 1

Si tiene una lista de direcciones URL de imágenes en la columna A, y ahora, desea descargar las imágenes correspondientes de las URL y mostrarlas en la columna B adyacente como se muestra en la captura de pantalla de la izquierda. En Excel, ¿cómo podría extraer las imágenes reales de las URL de las imágenes de forma rápida y sencilla?

Convierta las URL de la imagen en imágenes reales con código VBA

Convierta las URL de la imagen en imágenes reales con Kutools para Excel


Convierta las URL de la imagen en imágenes reales con código VBA

El siguiente código VBA puede ayudarlo a extraer rápidamente las imágenes reales de las direcciones URL de la imagen, haga lo siguiente:

1. Mantenga pulsado el ALT + F11 teclas para abrir la ventana de Microsoft Visual Basic para Aplicaciones.

2. Hacer clic recuadro > Móduloy pegue el siguiente código en la ventana del módulo.

Código de VBA: convierta las URL de la imagen en imágenes reales:

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

Notas: 

  • 1. En el código anterior, A2: A5 es el rango de celdas que contiene las direcciones URL de las que desea extraer las imágenes, debe cambiar las referencias de celda según sus necesidades.
  • 2. Con este código, no puede especificar el tamaño de las imágenes extraídas a su necesidad.
  • 3. El código anterior solo puede extraer las imágenes reales en las celdas además de su columna URL, no puede especificar la celda para generar las imágenes.
  • 4. Debe tener algunos conocimientos básicos del código, si falta algún carácter o es incorrecto, el código no se ejecutará correctamente.

3. Entonces presione F5 clave para ejecutar este código, y todas las imágenes correspondientes se han extraído de las URL de la imagen a la columna adyacente a la vez, y las imágenes se colocarán en el centro de sus celdas específicas, vea la captura de pantalla:

URL del documento a img 2


Convierta las URL de la imagen en imágenes reales con Kutools para Excel

Si no está familiarizado con el código VBA o desea remediar la limitación del código anterior, Kutools for Excel's Insertar imágenes desde la ruta (URL) La función puede ayudarlo a insertar rápidamente las imágenes correspondientes a cpr según las direcciones URL o la ruta específica en su computadora, como se muestra a continuación. ¡Haga clic para descargar Kutools para Excel!

Note:Para aplicar esto Insertar imágenes desde la ruta (URL), en primer lugar, debe descargar el Kutools for Excely, a continuación, aplique la función de forma rápida y sencilla.

Después de instalar Kutools for Excel, haz lo siguiente:

1. Hacer clic Kutools > recuadro > Insertar imágenes desde la ruta (URL), en el cuadro de diálogo emergente, configure las siguientes operaciones, vea las capturas de pantalla:

URL del documento a img 3 URL del documento a img 4

2. Luego, haz clic Ok botón, y las imágenes se extraerán de las URL, vea la captura de pantalla:

URL del documento a img 1

Haga clic para descargar y probar gratis Kutools para Excel ahora!

Las mejores herramientas de productividad de oficina

🤖 Asistente de IA de Kutools: Revolucionar el análisis de datos basado en: Ejecución inteligente   |  Generar codigo  |  Crear fórmulas personalizadas  |  Analizar datos y generar gráficos  |  Invocar funciones de Kutools...
Características populares: Buscar, resaltar o identificar duplicados   |  Eliminar filas en blanco   |  Combine columnas o celdas sin perder datos   |   Ronda sin fórmula ...
Super búsqueda: Búsqueda virtual de criterios múltiples    Búsqueda V de valores múltiples  |   VLookup en varias hojas   |   Búsqueda difusa ....
Lista desplegable avanzada: Crear rápidamente una lista desplegable   |  Lista desplegable dependiente   |  Lista desplegable de selección múltiple ....
Administrador de columnas: Agregar un número específico de columnas  |  Mover columnas  |  Toggle Estado de visibilidad de columnas ocultas  |  Comparar rangos y columnas ...
Características destacadas: Enfoque de cuadrícula   |  Vista de diseño   |   Gran barra de fórmulas    Administrador de hojas y libros de trabajo   |  Biblioteca de Recursos (Texto automático)   |  Selector de fechas   |  Combinar hojas de trabajo   |  Cifrar/descifrar celdas    Enviar correos electrónicos por lista   |  Súper filtro   |   Filtro especial (filtro negrita/cursiva/tachado...) ...
Los 15 mejores conjuntos de herramientas12 Texto Herramientas (Añadir texto, Quitar caracteres, ...)   |   50+ Tabla Tipos (Diagrama de Gantt, ...)   |   40+ Práctico Fórmulas (Calcular la edad según el cumpleaños, ...)   |   19 Inserción Herramientas (Insertar código QR, Insertar imagen desde la ruta, ...)   |   12 Conversión Herramientas (Números a palabras, Conversión de Moneda, ...)   |   7 Fusionar y dividir Herramientas (Filas combinadas avanzadas, Células partidas, ...)   |   ... y más

Mejore sus habilidades de Excel con Kutools for Excel y experimente la eficiencia como nunca antes. Kutools for Excel ofrece más de 300 funciones avanzadas para aumentar la productividad y ahorrar tiempo.  Haga clic aquí para obtener la función que más necesita...

Descripción


Office Tab lleva la interfaz con pestañas a Office y hace que su trabajo sea mucho más fácil

  • Habilite la edición y lectura con pestañas en Word, Excel, PowerPoint, Publisher, Access, Visio y Project.
  • Abra y cree varios documentos en nuevas pestañas de la misma ventana, en lugar de en nuevas ventanas.
  • ¡Aumenta su productividad en un 50% y reduce cientos de clics del mouse todos los días!
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