![]() |
|
Forum
|
|
|
#1 (permalink) |
|
XLDnaute Nouveau
Date d'inscription: juin 2007
Messages: 1
|
Bonjour
Je suis en train de réaliser un travail sur EXCEL et je me retrouve confronté à un certain problème. J'ai réalisé un liste déroulante avec le nom de différentes personnes. Et je voudrais qu'en fonction de la personne sélectionnée, sa photo apparaisse à côté de la liste déroulante. Qui peut m'aider.????? Merci d'avance!! |
|
|
|
| ANNONCES | |||
|
|
|
|
#3 (permalink) |
|
XLDnaute Impliqué
Date d'inscription: février 2005
Messages: 554
|
Bonjour,
J'adore l'intégration de photo dans xl! Ci-joint une petite démo (ici avec une paire de GIF, mais on peut mettre du JPG ou du BMP) Le principe consiste en une macro évenementielle au changement de valeur : Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Image As String, LargeurImage As Single, Gauche As Single
Dim sh As Shape, tatiak As Object
If Not Intersect(Target, Range("A2")) Is Nothing Then
Call EffacePhoto
Image = ActiveWorkbook.Path & "\" & Target.Text & ".gif"
If Not ExisteGIF(Image) Then Image = ActiveWorkbook.Path & "\" & Target.Text & ".JPG"
If Not ExisteGIF(Image) Then Image = ActiveWorkbook.Path & "\" & Target.Text & ".BMP"
If Not ExisteGIF(Image) Then Image = ActiveWorkbook.Path & "\PasImage.GIF"
If ExisteGIF(Image) Then
Set tatiak = Sheets("Feuil1").Pictures.Insert(Image)
With Range("Feuil1!A1")
LargeurImage = (tatiak.Width * .Height / tatiak.Height) * 0.9
Gauche = .Left + (.Offset(0, 1).Left - .Left - LargeurImage) / 2
tatiak.Delete
Set sh = Sheets("Feuil1").Shapes.AddShape(msoShapeRectangle, _
Gauche, .Top, .Width, .Height)
sh.Name = "Img" & .Value
sh.Fill.UserPicture Image
sh.Height = .Height * 0.9
sh.Width = LargeurImage
End With
End If
End If
End Sub
... et à 2 p'tites macro de complément : Code:
Sub EffacePhoto()
Dim sh As Object
For Each sh In Sheets("Feuil1").Shapes
If Left(sh.Name, 3) = "Img" Then sh.Delete
Next sh
End Sub
Public Function ExisteGIF(Image As String) As Boolean
Dim tatiak As Object
Set tatiak = CreateObject("Scripting.FileSystemObject")
ExisteGIF = tatiak.FileExists(Image)
End Function
![]()
__________________
Visitez le Blog-à-tatiak! |
|
|
|
| ANNONCES | |
![]() |
| Liens sociaux |
| Outils de la discussion | |
|
|
Discussions similaires
|
||||
| Discussion | Auteur | Forum | Réponses | Dernier message |
| Afficher une photo.jpeg dans une liste déroulante | papy10vn | Forum Excel | 3 | 05/06/2007 16h23 |
| comment insérer une liste déroulante sous excel ? | auré1223 | Forum Excel | 4 | 14/06/2005 14h06 |
| Insérer une liste déroulante | Matt | Forum Excel Downloads - Archives | 5 | 15/07/2004 14h24 |
| inserer ou un symbole dans une liste deroulante | tom | Forum Excel Downloads - Archives | 1 | 26/07/2003 04h26 |
| inserer un symbole ou image dans une liste deroulante | tom | Forum Excel Downloads - Archives | 1 | 26/07/2003 02h48 |