XL 2016 Convertir liens hypertexte en image

hjfe

XLDnaute Nouveau
Bonjour,
Je possède un tableau avec des liens hypertextes menant à des images. Je voudrais pouvoir afficher ces images dans une colonne à côté. Est-ce que qqun saurait comment faire ?
Merci d’avance !
 

job75

XLDnaute Barbatruc
Bonjour hjfe, le forum,

Téléchargez les fichiers zippés joints dans le même dossier et voyez la macro du bouton :
VB:
Sub Images()
Dim ps$, h As Hyperlink, had$, p%, ext$, c As Range, cad$, s As Shape
ps = Application.PathSeparator
Application.ScreenUpdating = False
With Sheets("Feuil1") 'à adapter
    .Visible = xlSheetVisible 'au cas où...
    For Each h In .Hyperlinks
        had = h.Address
        p = InStrRev(had, ".")
        If p Then
            ext = Mid(had, p)
            If ext = ".jpg" Or ext = ".jpeg" Or ext = ".png" Or ext = ".gif" Or ext = ".tiff" Then
                If Not had Like "?:" & ps & "*" Then had = ThisWorkbook.Path & ps & had
                Set c = h.Parent.Offset(, 1) 'cellule à droite
                cad = c.Address
                For Each s In .Shapes
                    If s.TopLeftCell.Address = cad Then s.Delete 'vide la cellule
                Next s
                With .Pictures.Insert(had) 'insère l'image dans la feuille
                    .ShapeRange.LockAspectRatio = msoTrue 'verrouille le rapport hauteur/largeur
                    .Height = c.Height - 2
                    If .Width > c.Width Then .Width = c.Width - 2
                    .Top = c.Top + (c.Height - .Height) / 2
                    .Left = c.Left + (c.Width - .Width) / 2
                End With
            End If
        End If
    Next h
End With
End Sub
A+
 

Pièces jointes

  • Dossuer.zip
    26.7 KB · Affichages: 27

Discussions similaires

Réponses
7
Affichages
468

Statistiques des forums

Discussions
312 161
Messages
2 085 852
Membres
103 005
dernier inscrit
gilles.hery