Microsoft 365 Récupération de l'image de la note dans UserForm

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Francky79

XLDnaute Occasionnel
Bonjour le forum,

Est-il possible de récupérer l'image dans une note et de l'insérer dans un UserForm ?
Aucune idée sur le moyen de la faire.
Voir fichier en pièce jointe.
Merci pour votre aide,
 

Pièces jointes

Francky79

Il y avait 2 soucis sur le code trouvé, ça ne semblait fonctionner qu'une fois et l'image supprimée était celle du commentaire 😱

J'ai changé tout ça et je crée l'image à l'aide d'un graphique

Cela fonctionne parfaitement de mon côté, à voir de ton côté 😉

A+
 

Pièces jointes

bonjour bruno
j'ai fait un peu d’élagage dans ta fonction
et je la renomme car la mienne c'est pour exporter en wmf le graphique exporte en gif ou jpeg


VB:
Public MonImg As String
Dim ImgTemp$
Sub V()
    Dim Lig As Long
    Lig = ActiveCell.Row
    Application.ScreenUpdating = False
    MonImg = ConvertAllShapeToJPG(Range("Y" & ActiveCell.Row))
    Application.ScreenUpdating = True
    With UserForm6
        .TextBox1.Text = ActiveCell.Value
        .TextBox2.Text = Range("B" & Lig).Value
        .TextBox3.Text = Range("C" & Lig).Value
        .TextBox7.Text = Range("E" & Lig).Value
        .TextBox4.Text = Range("G" & Lig).Value
        .TextBox5.Text = Range("H" & Lig).Value
        .TextBox6.Text = Range("I" & Lig).Value
        .TextBox8.Text = Range("AQ" & Lig).Value
        .TextBox9.Text = Range("J" & Lig).Value
        .TextBox10.Text = Range("K" & Lig).Value
        .TextBox11.Text = Range("L" & Lig).Value
        .TextBox12.Text = Range("M" & Lig).Value
        .TextBox13.Text = Range("O" & Lig).Value
        .TextBox14.Text = Range("N" & Lig).Value
        .TextBox15.Text = Range("Q" & Lig).Value
        .TextBox16.Text = Range("R" & Lig).Value
        .TextBox17.Text = Range("S" & Lig).Value
        .TextBox18.Text = Range("T" & Lig).Value
        .TextBox19.Text = Range("U" & Lig).Value
        Set commentaire = Range("W" & Lig).Comment
        If Not commentaire Is Nothing Then .TextBox20 = Range("W" & Lig).Comment.Text
        Set commentaire = Range("W" & Lig).Comment
        If Not commentaire Is Nothing Then .TextBox21 = Range("X" & Lig).Comment.Text
        .TextBox22.Text = Range("V" & Lig).Value
        .TextBox23.Text = Range("W" & Lig).Value
        .TextBox24.Text = Range("X" & Lig).Value
        .TextBox25.Text = Range("Y" & Lig).Value
        .Image1.Picture = LoadPicture(MonImg)
        .Show
    End With

End Sub

Function ConvertAllShapeToJPG(Rng As Range)
    Dim Shp As Shape, ShpRng As ShapeRange, oChrtO As ChartObject

    With Rng.Comment

        .Visible = True

        .Shape.CopyPicture

        ImgTemp = Environ("userprofile") & "\AppData\Local\Temp\a.jpg"    'si tu veux

        Set oChrtO = ActiveSheet.ChartObjects.Add(Left:=0, Top:=0, Width:=.Shape.Width, Height:=.Shape.Height)

        oChrtO.Chart.ChartArea.Format.Line.Visible = msoFalse

        .Visible = False

    End With

    With oChrtO.Chart

        .Paste

        .Export Filename:=ImgTemp, Filtername:="JPG"

        .Parent.Delete

    End With

    ConvertAllShapeToJPG = ImgTemp    ' return path image

    Application.OnTime Now + 0.0001, "killImage"
End Function

Sub killImage(): Kill ImgTemp: End Sub
pas la peine de faire un paste sur feuille pour re paster dans le chart
le height et width tu le prends sur le .comment.shape.(height ou width)
on y vois plus clair là d'un coup non?😉
et bien sur on supprime l'image temporaire crée aussi
 
Dernière édition:
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
7
Affichages
163
Réponses
3
Affichages
176
  • Question Question
Microsoft 365 affichage userform
Réponses
4
Affichages
372
Retour