Transformieren Sie URL-Pfade im JPG-Format (kein PNG) in tatsächliche Bildeinfügungen in Excel

Transformieren Sie URL-Pfade im JPG-Format (kein PNG) in tatsächliche Bildeinfügungen in Excel

Ich habe Mühe, den VBA-Code zu finden, der mir helfen würde, URL-Pfade im JPG-Format (NICHT im PNG-Format) in tatsächliche Bildeinfügungen in Excel umzuwandeln. Es gibt eine Reihe von VBAs, die funktionieren, aber nur, wenn die URLs PNG-Fotos enthalten.

Ich begann zu glauben, dass es im Grunde eine Excel-Einschränkung ist, Bilder von einem URL-Pfad anzeigen zu können.

wenn jemand von euch ein VBA kennt, das BILDER (JPG-FORMAT) von einem URL-PFAD nach Excel bringt und jedes einzelne Foto neben dem entsprechenden Link platziert, wäre das eine große Hilfe für mich.

https://viewworld-files-console.s3.amazonaws.com/assets/113441/preview/IMG_20190327_151722.jpg

Das ist einer der Links, bei denen ich das machen möchte.

Antwort1

Der folgende Code funktioniert für die URL, aber aus irgendeinem Grund blockiert der Server die von Ihnen angeforderte URL. Könnte es an Amazon Web Servers liegen?

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("https://images.pexels.com/photos/302743/pexels-photo-302743.jpeg").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

Antwort2

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("https://cdn.pixabay.com/photo/2018/02/07/20/58/girl- 
    3137998_960_720.jpg").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

verwandte Informationen