Voir aussi
Une image dans un commentaire
Comment mettre une photo dans un commentaire ?
Sans macro :
Fais un clic droit sur le bord du commentaire et choisis "Format de
commentaire". Choisis l'onglet "Couleurs et traits", dans la partie
"remplissage", clique sur la flèche de la liste déroulante "Couleur", clique
sur "Motifs et tectures", et sur l'onglet "Image", Clique sur "sélectionner
l'image" et choisis ton image.

avec macro
Sub ImageFondCommentaire()
ChDir ActiveWorkbook.Path
For Each c In ActiveSheet.Comments
c.Shape.Fill.UserPicture "fond_nico.jpg"
c.Shape.Height = 100
c.Shape.Width = 100
c.Shape.ScaleHeight 1.2, msoFalse, msoScaleFromTopLeft
c.Shape.ScaleWidth 1, msoFalse, msoScaleFromTopLeft
Next c
End Sub

ou encore
Sub Trombine()
ChDir ActiveWorkbook.Path
Range("A2").Select
Do While ActiveCell <> ""
ActiveCell.ClearComments
ActiveCell.AddComment
ActiveCell.Comment.Text Text:=ActiveCell.Value
ActiveCell.Comment.Shape.Fill.UserPicture ActiveCell.Value &
".jpg"
ActiveCell.Comment.Shape.Height = 50
ActiveCell.Comment.Shape.Width = 50
ActiveCell.Comment.Shape.ScaleHeight 1.2, msoFalse,
msoScaleFromTopLeft
ActiveCell.Comment.Shape.ScaleWidth 1, msoFalse,
msoScaleFromTopLeft
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Daniel Colardelle, Jacques Boisgontier,
Ajouté ou modifié le 16/03/2008 (N°1980)
Transférer le contenu d'une cellule dans un commentaire.
Comment copier le contenu d'une cellule dans un commentaire et effacer la cellule ?
Sub MettreContenuEnCommentaire()
'Trirème MPFE 2007

' La macro copie la valeur de la cellule dans le commentaire, éventuellement
' à la suite d'un commentaire déjà présent, puis efface le contenu de la cellule.
'
Dim c As Range
Dim Moi As String
' ************************
Moi = "PDK" ' À renseigner avec ses initiales
' ************************
For Each c In Selection
With c
If .Comment Is Nothing Then ' Le commentaire n'existe pas, on le crée
.AddComment
.Comment.Visible = False
.Comment.Text Text:=Moi & " (" & Date & ") :" & Chr(10) & "Ancienne valeur = " & c.Value
.ClearContents
Else ' Un commentaire existe déjà, on ajoute alors le nouveau à la fin de celui existant
.Comment.Text Text:=.Comment.Text & _
Chr(10) & Moi & " (" & Date & ") :" & _
Chr(10) & "Ancienne valeur = " & c.Value
End If
End With
Next c
End Sub
Trirème,
Ajouté ou modifié le 15/12/2007 (N°1947)
Commentaire vide à la création
Comment éviter d'avoir mon nom dans chaque commentaire ?
Tu ne peux pas paramétrer excel pour cela malheureusement. Utilise cette macro :

Sub AjoutCommentaire()
With ActiveCell.AddComment.Shape.OLEFormat.Object
.Text = ""
.Font.Name = "Arial"
.Font.Size = 12
.AutoSize = True
End With
SendKeys "%IM"
End Sub

Si tu t'en sers souvent tu peux la relier à un bouton ou, via une acro événeentielle, au double clic dans la cellule.
ChrisV,
Ajouté ou modifié le 27/10/2007 (N°1915)
Commentaires et tri
J'ai une grande feuille de calcul pleine de commentaires. Lorsque j'effectue un tri tous les commentaires sont éparpillés Comment faire pour ré-aligner tous les commentaires à leurs cellules respectives en une seule manip ?
Sub RepositionnerCommentaire()
Dim c
For Each c In Cells.SpecialCells(xlCellTypeComments)
With c.Comment.Shape
.Left = c.Left + c.Width + 8
.Top = c.Top - 5
End With
Next
End Sub


...pour que le commentaire suive la cellule lorsque celle ci est déplacée

Sub RepositionnerCommentaireEtFixerAuCellule()
Dim c
For Each c In Cells.SpecialCells(xlCellTypeComments)
With c.Comment.Shape
.Left = c.Left + c.Width + 8
.Top = c.Top - 5
.Placement = xlMoveAndSize
End With
Next
End Sub

en sélectionnant le commentaire tu fais un clic droit et choisis format de commentaire. Dans
l'onglet propriété il y a
-déplacer et dimentionner avec les cellules
qui équivaut à
Placement = xlMoveAndSize
Isabelle, (N°1180)
Texte d'un commentaire
Existe-t-il une formule qui écrit le commentaire d'une cellule dans une autre sous forme de texte?
Sans VBA, je ne connais pas, mais en VBA, on peut faire ceci

Range("d5") = Range("b2").Comment.Text

On peut aussi créer une fonction personnalisée, à utiliser dans Excel.

Function Commentaire(Cellule As Range)
Commentaire = Cellule.Comment.Text
End Function
Pierre Fauconnier, (N°1179)
Taille de police des commentaires
Comment peut-on augmenter la taille de la police des commentaires ?
Pour modifier par ex. la taille du commentaire (automatique), la police, la
taille de la police, et la couleur de fond du commentaire:

Sub Ajust_Commentaires()
Dim Wks As Worksheet, Cmt As Comment
For Each Wks In Worksheets
For Each Cmt In Wks.Comments

Cmt.Shape.OLEFormat.Object.AutoSize = True
With Cmt.Shape.OLEFormat.Object.Font
.Name = "Tahoma"
.Size = 10

End With
Cmt.Shape.OLEFormat.Object.ShapeRange.Fill _
.ForeColor.SchemeColor = 42
Next Cmt
Next Wks
End Sub
ChrisV, (N°1178)
Une image dans un commentaire
Est possible d'insérer une image (JPG ou GIF) dans un commentaire ? Quand la fenêtre commentaire est ouverte en édition, on a accès à "Insertion, Image", mais toutes les sous-options sont grisées, ce qui est très frustrant !! Y aurait-il un truc ?
Il ne faut pas être en mode Edition pour insérer une image, car dans ce
mode, tu n'as accès qu'à l'onglet Police. Tu insères un commentaire dont tu effaces le texte,
puis clic droit "sur la bordure" du commentaire - Format de commentaire- Onglet
Couleurs et traits - clic sur Couleur, puis Motifs et textures, Onglet Image puis clic sur le
bouton "Image..." et tu va rechercher le fichier que tu veux sur ton DD et
enfin OK et OK.
Voila ton image dans la fenêtre du commentaire.
Richard Hermann, (N°1177)
Format de commentaire
Comment peut-on imposer un format aux commentaires des cellules ?
il y a dans Format de commentaire plusieurs onglets dont,
Alignement: décoche, taille automatique
Dimension: décoche, Proportionnel
Propriété: coche, Déplacer sans dimensionner avec les cellules

Autre solution : cette macro ajoute des commandes dans le menu contextuel et permet d'ouvrir
une fenêtre de commentaire paramétrée à ta guise (pas de nom de l'utilisateur et adaptation
automatique de la dimension en fonction du contenu) tout en gardant la possibilité d'utiliser
la commande habituelle d'Excel.

***A copier dans le module ThisWorkbook***

Private Sub Workbook_AddinInstall()
Set ctrl = Application.CommandBars("Cell").FindControl(Id:=2031)
With Application.CommandBars("Cell").Controls. _
Add(Type:=msoControlButton, before:=ctrl.Index + 1)
.Caption = "Commentaire vierge"
.OnAction = "CommentaireMonique"
End With
End Sub

Private Sub Workbook_AddinUninstall()
Application.CommandBars("Cell").Controls("Commentaire vierge").Delete
End Sub

***A copier dans un module normal***

Option Private Module

Sub CommentaireMonique()
Set cmt = ActiveCell.AddComment
With cmt.Shape
.Placement = xlFreeFloating
.TextFrame.AutoSize = True
With .OLEFormat.Object
With .Font
.Name = "Times New Roman": .Size = 14: .Color = vbRed
End With
End With
End With
cmt.Text Text:=""
SendKeys "%IM"
End Sub

Bien-sûr, tu adaptes à tes propres souhaits et tu sauves en .xla
Isabelle, Frédéric Sigonneau, (N°1176)
Couleur de l'onglet commentaires
Comment changer la couleur de l'Onglet rouge des commentaires
Ci-dessous, une fonction qui peut faire ça (d'un contributeur connu du forum anglophone). Le(s)
commentaire(s) doivent commencer par le nom d'utilisateur qu'Excel inscrit par défaut (en gras,
suivi de :).



'=================
Sub test_fncCreateCommentIndicator()
fncCreateCommentIndicator vbBlue, "nomDeLUtilisateur"
End Sub

Public Function fncCreateCommentIndicator(CommentIndicatorColor As Long, _
CommentIndicatorName As String) As Boolean
'covers the comment indicators in the activeworkbook with a similar
'triangle of the specified color, based on the Application.UserName property
'Stratos Malasiotis (microsoft.public.excel.programming)
Dim IDnumber As Long
Dim aCell As Range
Dim aComment As Comment
Dim aShape As Shape
Dim aWorksheet As Worksheet
Dim aWorkbook As Workbook
fncCreateCommentIndicator = False
'check whether a code name has been entered
If CommentIndicatorName = vbNullString Then GoTo ExitFunction
On Error GoTo ExitFunction
Set aWorkbook = ActiveWorkbook
IDnumber = 0
'loop through all wprksheets in the active workbook and all comments
'in each worksheet and create the comment shapes
For Each aWorksheet In aWorkbook.Worksheets
For Each aShape In aWorksheet.Shapes
If Left(aShape.Name, Len(CommentIndicatorName)) = _
CommentIndicatorName Then
aShape.Delete
End If
Next aShape
For Each aComment In aWorksheet.Comments
Set aCell = aComment.Parent
If InStr(1, aComment.Shape.TextFrame.Characters.Text, ":") > 0 Then
If Left(aComment.Shape.TextFrame.Characters.Text, InStr(1,
aComment.Shape.TextFrame.Characters.Text, ":") - 1) = Application.UserName Then
GoSub CreateCommentIndicator
End If
End If
Next aComment
Next aWorksheet
fncCreateCommentIndicator = True
ExitFunction:
On Error GoTo 0
Set aCell = Nothing
Set aComment = Nothing
Set aShape = Nothing
Set aWorksheet = Nothing
Set aWorkbook = Nothing
Exit Function
CreateCommentIndicator:
Set aShape = aWorksheet.Shapes.AddShape(Type:=msoShapeRightTriangle, _
Left:=aCell.Left + aCell.Width - 5, _
Top:=aCell.Top, _
Width:=5, _
Height:=5)
IDnumber = IDnumber + 1
With aShape
.Name = CommentIndicatorName & CStr(IDnumber)
.IncrementRotation -180#
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.RGB = CommentIndicatorColor
.Line.Visible = msoTrue
.Line.Weight = 1
.Line.Style = msoLineSingle
.Line.DashStyle = msoLineSolid
.Line.ForeColor.RGB = CommentIndicatorColor
.Placement = xlMove
End With
Return
End Function
' -------------------------------------------------
' As it is now it will colour only the comments that keep the default name
' given by excel (Application.username)
Stratos, Frédéric Sigonneau, (N°1175)
Nom par défaut dans les commentaires.
Comment supprimer le nom qui apparaît par défaut dans les commentaires ?
Pas d'autre moyen d'obtenir un commentaire vraiment vierge que par VBA

'===========dans le module ThisWorkbook d'un classeur neuf
Private Sub Workbook_AddinInstall()
Dim Ctrl As CommandBarControl

On Error Resume Next
Set Ctrl = Application.CommandBars("Cell").FindControl(ID:=2031)
With Application.CommandBars("Cell").Controls. _
Add(Type:=msoControlButton, before:=Ctrl.Index + 1)
.Caption = "Commentaire vierge"
.OnAction = "CommentaireMonique"
End With
End Sub

Private Sub Workbook_AddinUninstall()
On Error Resume Next
Application.CommandBars("Cell").Controls("Commentaire vierge").Delete
End Sub
'==============================

puis dans un module standard
'==============================
Sub CommentaireMonique()

On Error Resume Next
Set cmt = ActiveCell.AddComment
If Err <> 0 Then GoTo Fin

With cmt.Shape
.Placement = xlFreeFloating
.TextFrame.AutoSize = True
With .OLEFormat.Object
With .Font
.Name = "Times New Roman": .Size = 14: .Color = vbRed
End With
End With
End With
cmt.Text Text:=""
Fin:
SendKeys "%IM"
End Sub
'==============================

Enregistre comme macro complémentaire (.xla).
Lorsque la macro complémentaire est installée, une commande "Commentaire vierge" est
ajoutée au menu contextuel des cellules. Tu peux modifier à ta convenance les caractéristiques
des commentaires insérés dans la procédure "CommentaireMonique".
Frédéric Sigonneau, (N°1174)
Commentaire conditionnel
Je voudrais afficher un commentaire dans une cellule en fonction de l'état d'un option button dans un userform : si le bouton est coché alors rajouter à la cellule D25 le commentaire "attention..."
Private Sub opt_1_Click()
If Me.opt_1 = -1 Then
Worksheets("kkkk").Range("D25").Comment.Text ("Bonjour" & Chr(10) & "La case est cochée")
Else
Worksheets("kkkk").Range("D25").Comment.Text ("Bonjour" & Chr(10) & "La case est pas cochée")
End If
End Sub
on est pas obligé de déclencher l'événement avec le clic sur le bouton d'option biensur
Pierre CFI, (N°1173)