ajuster taille commentaire - macro à modifier ?

starz

XLDnaute Occasionnel
Bonjour,
j'utilise depuis longtemps cette macro :

Code:
Sub imgComment()
Dim nom$
On Error Resume Next
For Each c In Selection
nom = c.Value
With c
.AddComment
.Comment.Shape.Fill.UserPicture ActiveWorkbook.Path & "\" & nom & ".jpg"
End With
Next
End Sub

mais je souhaiterai que quelqu'un d'entre vous m'aide pour que, quand j'execute ma macro, la taille du commentaire s'adapte à la taille de l'image.

merci
 

tactic6

XLDnaute Impliqué
Re : ajuster taille commentaire - macro à modifier ?

Bonjour
trouvé sur le forum avec la fonction recherche
Code:
'De: Dana DeLouis <dana2@email.msn.com>

Sub Comments_AutoSize()
  Dim MyComments As Comment
  Dim lArea As Long
  For Each MyComments In ActiveSheet.Comments
    With MyComments
      .Shape.TextFrame.AutoSize = True
      If .Shape.Width > 300 Then
        lArea = .Shape.Width * .Shape.Height
        .Shape.Width = 200
        ' An adjustment factor of 1.1 seems to work ok.
        .Shape.Height = (lArea / 200) * 1.1
      End If
    End With
  Next ' comment
End Sub

a adapter
 

CB60

XLDnaute Barbatruc
Re : ajuster taille commentaire - macro à modifier ?

Bonsoir
regarde si cela te convient, une adaptation d'une macro de JB
mettre en A1 la valeur de la hauteur ( exemple 200)
mettre en A2 la valeur de la largeur ( exemple 150)
Code:
Sub PhotoCommentaire()
 Choixa = [a1].Value
 choixb = [a2].Value
  For Each photo In ActiveSheet.Comments
    photo.Shape.Height = Choixa 'HAUTEUR
    photo.Shape.Width = choixb ' LARGEUR
  Next photo
End Sub
 

Discussions similaires

Réponses
0
Affichages
155

Statistiques des forums

Discussions
312 304
Messages
2 087 059
Membres
103 444
dernier inscrit
Aeggie78