Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

[Excel 2013] Insertion Image récalcitrante

4 réponses
Avatar
ThierryP
Bonjour le forum,

Il m'arrive un truc bizarre autant qu'=C3=A9trange : Si j'ins=C3=A8re une i=
mage dans un fichier Excel par le menu classique, je peux d=C3=A9placer mon=
fichier sur une autre machine, l'image est toujours "dans" le fichier.

Si je fais l'op=C3=A9ration par macro, l'image ne suit pas le fichier,et j'=
ai =C3=A0 la place le message d'insulte classique : "Impossible d'afficher =
l'image li=C3=A9e" etc...

J'ai enregistr=C3=A9 la macro en utilisant le menu Insertion, =C3=A7a me do=
nne =C3=A7=C3=A0 :
'---------------------
Sub Macro1()
ActiveSheet.Pictures.Insert("E:\1.jpg").Select
Selection.ShapeRange.IncrementLeft 129.75 'Essais de manip sur l'imag=
e
Selection.ShapeRange.IncrementTop 21
Selection.ShapeRange.ScaleWidth 0.701980198, msoFalse, msoScaleFromBott=
omRight
Selection.ShapeRange.ScaleHeight 0.7019802212, msoFalse, _
msoScaleFromBottomRight
Selection.ShapeRange.IncrementLeft -159.75
Selection.ShapeRange.IncrementTop -90
Selection.ShapeRange.ScaleWidth 0.7016712756, msoFalse, msoScaleFromTop=
Left
Selection.ShapeRange.ScaleHeight 0.7016712903, msoFalse, _
msoScaleFromBottomRight
End Sub
'--------------

Ma macro =C3=A0 moi :
Rapport.Pictures.Insert(Lecteur & "\Signatures\Images\Signature.jpg").Selec=
t
Selection.Name =3D "Signature.jpg"
Selection.Left =3D Range("Signature")(1).Left
Selection.Top =3D Range("Signature")(1).Top + 0.5
Rapport.Shapes("Signature.jpg").LockAspectRatio =3D msoFalse
Selection.Height =3D Range("Signature").Height - 0.5
Selection.Width =3D Range("Signature").Width

Si quelqu'un a un semblant de bout de d=C3=A9but d'explication, je suis pre=
neur !

Merci d'avance,

ThierryP

4 réponses

Avatar
DanielCo
Bonjour,
Essaie comme ça :
Set Image =
ActiveSheet.Shapes.AddPicture("C:UsersdcolaPictures2016_08_07IMG_2778.JPG",
_
False, True, 100, 100, 70, 70)
Cordialement.
Daniel
Bonjour le forum,
Il m'arrive un truc bizarre autant qu'étrange : Si j'insère une image
dans un fichier Excel par le menu classique, je peux déplacer mon
fichier sur une autre machine, l'image est toujours "dans" le
fichier.
Si je fais l'opération par macro, l'image ne suit pas le fichier,et
j'ai à la place le message d'insulte classique : "Impossible
d'afficher l'image liée" etc...
J'ai enregistré la macro en utilisant le menu Insertion, ça me donne
çà : '---------------------
Sub Macro1()
ActiveSheet.Pictures.Insert("E:1.jpg").Select
Selection.ShapeRange.IncrementLeft 129.75 'Essais de manip sur
l'image Selection.ShapeRange.IncrementTop 21
Selection.ShapeRange.ScaleWidth 0.701980198, msoFalse,
msoScaleFromBottomRight Selection.ShapeRange.ScaleHeight
0.7019802212, msoFalse, _ msoScaleFromBottomRight
Selection.ShapeRange.IncrementLeft -159.75
Selection.ShapeRange.IncrementTop -90
Selection.ShapeRange.ScaleWidth 0.7016712756, msoFalse,
msoScaleFromTopLeft Selection.ShapeRange.ScaleHeight
0.7016712903, msoFalse, _ msoScaleFromBottomRight
End Sub
'--------------
Ma macro à moi :
Rapport.Pictures.Insert(Lecteur &
"SignaturesImagesSignature.jpg").Select Selection.Name =
"Signature.jpg" Selection.Left = Range("Signature")(1).Left
Selection.Top = Range("Signature")(1).Top + 0.5
Rapport.Shapes("Signature.jpg").LockAspectRatio = msoFalse
Selection.Height = Range("Signature").Height - 0.5
Selection.Width = Range("Signature").Width
Si quelqu'un a un semblant de bout de début d'explication, je suis
preneur !
Merci d'avance,
ThierryP
Avatar
isabelle
bonjour Thierry,
j'ai fais un test sur xl2010,
j'espère que cela fonctionnera sur xl2013
Sub Insert_Image()
Dim CheminImage As String, Lecteur As String, rng As Range
Set rng = Range("D6")
Lecteur = "C:"
CheminImage = Lecteur & "SignaturesImagesSignature.jpg"
ActiveSheet.Pictures.Insert (CheminImage)
With ActiveSheet.Shapes(1)
.LockAspectRatio = msoFalse
.Top = rng.Top + 0.5
.Left = rng.Left
.Width = rng.Width
.Height = rng.Height - 0.5
End With
End Sub
isabelle
Le 2017-03-01 à 05:05, ThierryP a écrit :
Ma macro à moi :
Rapport.Pictures.Insert(Lecteur & "SignaturesImagesSignature.jpg").Select
Selection.Name = "Signature.jpg"
Selection.Left = Range("Signature")(1).Left
Selection.Top = Range("Signature")(1).Top + 0.5
Rapport.Shapes("Signature.jpg").LockAspectRatio = msoFalse
Selection.Height = Range("Signature").Height - 0.5
Selection.Width = Range("Signature").Width
Avatar
isabelle
ps/
il faudrait modifier cette ligne
With ActiveSheet.Shapes(1)
par
With ActiveSheet.Shapes(ActiveSheet.Shapes.Count)
isabelle
Le 2017-03-01 à 10:25, isabelle a écrit :
bonjour Thierry,
j'ai fais un test sur xl2010,
j'espère que cela fonctionnera sur xl2013
Sub Insert_Image()
Dim CheminImage As String, Lecteur As String, rng As Range
Set rng = Range("D6")
Lecteur = "C:"
CheminImage = Lecteur & "SignaturesImagesSignature.jpg"
ActiveSheet.Pictures.Insert (CheminImage)
With ActiveSheet.Shapes(1)
.LockAspectRatio = msoFalse
.Top = rng.Top + 0.5
.Left = rng.Left
.Width = rng.Width
.Height = rng.Height - 0.5
End With
End Sub
isabelle
Le 2017-03-01 à 05:05, ThierryP a écrit :
Ma macro à moi :
Rapport.Pictures.Insert(Lecteur & "SignaturesImagesSignature.jpg").Select
Selection.Name = "Signature.jpg"
Selection.Left = Range("Signature")(1).Left
Selection.Top = Range("Signature")(1).Top + 0.5
Rapport.Shapes("Signature.jpg").LockAspectRatio = msoFalse
Selection.Height = Range("Signature").Height - 0.5
Selection.Width = Range("Signature").Width
Avatar
ThierryP
Bonjour Isabelle,
Merci d'avoir testé !
En fait, j'utilisais la méthode proposée par Daniel (que je remer cie au passage, ça fonctionne !!!). Comme j'ai d'autres images/boutons /cases sur la feuille, le seul souci que j'avais était de pouvoir reno mmer l'image afin de pouvoir tester son existence.
Du coup, je boucle sur les shapes pour trouver le bon et le renommer et tou t roule.
Merci Isabelle et Daniel !
ThierryP
bonjour Thierry,
j'ai fais un test sur xl2010,
j'espère que cela fonctionnera sur xl2013