OVH Cloud OVH Cloud

police d'un commentaire

5 réponses
Avatar
yan
bonjour à tous
Est-il possible par vba de modifier la police du texte d'un commentaire
(gras, italique, couleur.....)
Merci
A+
Yan

5 réponses

Avatar
jps
bonjour yan
voici ce qu'écrivit un lointain mais non moins émérite contributeur :

Sub changeCommentFont()
For Each cmt In ActiveSheet.Comments
With cmt.Shape.TextFrame.Characters.Font
.Name = "Arial"
.Italic = True
.Size = 9
End With
Next
End Sub

HTH
jps

"yan" a écrit dans le message de news:
454e389f$0$5110$
bonjour à tous
Est-il possible par vba de modifier la police du texte d'un commentaire
(gras, italique, couleur.....)
Merci
A+
Yan



Avatar
MichDenis
Cette procédure modifie le caractère gras et italique que pour le mot "Tout" du commentaire
'-----------------------
Sub test()

Dim Sh As Shape
With Feuil1.Range("e5").Comment
.Text "Bonjour tout le monde"
With .Shape
With .TextFrame.Characters(9, 4)
.Font.Bold = True
.Font.Italic = True
End With
End With
End With
End Sub
'-----------------------

Si on désire modifier le format pour tout le commentaire :
'----------------------
Sub test()

With Feuil1.Range("e5").Comment.Shape.OLEFormat.Object
.Font.Name = "Arial"
.Font.Bold = True
.Font.Italic = True
End With

End Sub
'----------------------




"yan" a écrit dans le message de news: 454e389f$0$5110$
bonjour à tous
Est-il possible par vba de modifier la police du texte d'un commentaire
(gras, italique, couleur.....)
Merci
A+
Yan
Avatar
JB
Bonsoir,

Modifie la totalité du commentaire:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If ActiveCell.NoteText = "" Then
Target.AddComment
Target.Comment.Text Text:=CStr(Now) & Chr(10) &
Environ("username") & Chr(10)
lg = Len(Target.Comment.Text)

With Target.Comment.Shape.OLEFormat.Object.Font
.Name = "Tverdana"
.Size = 8
.FontStyle = "Normal"
.ColorIndex = 3
End With

SendKeys "m"
Else
SendKeys "m"
End If
End Sub

Modifie une partie du commentaire seulement:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If ActiveCell.NoteText = "" Then
Target.AddComment
Target.Comment.Text Text:=CStr(Now) & Chr(10) &
Environ("username") & Chr(10)
lg = Len(Target.Comment.Text)
With Target.Comment.Shape.TextFrame
.Characters(Start:=1, Length:=lg).Font.Name = "Verdana"
.Characters(Start:=1, Length:=lg).Font.Size = 8
.Characters(Start:=1, Length:=lg).Font.Bold = True
.Characters(Start:=1, Length:=lg).Font.Italic = True
.Characters(Start:=1, Length:=lg).Font.ColorIndex = 3

.Characters(Start:=lg, Length:™).Font.Bold = False
.Characters(Start:=lg, Length:™).Font.Italic = False
.Characters(Start:=lg, Length:™).Font.ColorIndex = 1
End With
SendKeys "m"
Else
SendKeys "m"
End If
End Sub

http://cjoint.com/?lfwRpuT2Tp

JB


bonjour à tous
Est-il possible par vba de modifier la police du texte d'un commentaire
(gras, italique, couleur.....)
Merci
A+
Yan


Avatar
MichDenis
| If ActiveCell.NoteText = "" Then
| Target.AddComment

Si comme tu l'as écrit, si le commentaire n'a aucun text,
(y compris un espace provenant de la barre d'espacement)
Target.AddComment va se planter ....

Si par ce test, tu voulais tester la présence d'un commentaire
pour la cellule active... ce n'est pas une méthode efficace pour
arriver à cette fin.



"JB" a écrit dans le message de news:

Bonsoir,

Modifie la totalité du commentaire:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If ActiveCell.NoteText = "" Then
Target.AddComment
Target.Comment.Text Text:=CStr(Now) & Chr(10) &
Environ("username") & Chr(10)
lg = Len(Target.Comment.Text)

With Target.Comment.Shape.OLEFormat.Object.Font
.Name = "Tverdana"
.Size = 8
.FontStyle = "Normal"
.ColorIndex = 3
End With

SendKeys "m"
Else
SendKeys "m"
End If
End Sub

Modifie une partie du commentaire seulement:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
If ActiveCell.NoteText = "" Then
Target.AddComment
Target.Comment.Text Text:=CStr(Now) & Chr(10) &
Environ("username") & Chr(10)
lg = Len(Target.Comment.Text)
With Target.Comment.Shape.TextFrame
.Characters(Start:=1, Length:=lg).Font.Name = "Verdana"
.Characters(Start:=1, Length:=lg).Font.Size = 8
.Characters(Start:=1, Length:=lg).Font.Bold = True
.Characters(Start:=1, Length:=lg).Font.Italic = True
.Characters(Start:=1, Length:=lg).Font.ColorIndex = 3

.Characters(Start:=lg, Length:™).Font.Bold = False
.Characters(Start:=lg, Length:™).Font.Italic = False
.Characters(Start:=lg, Length:™).Font.ColorIndex = 1
End With
SendKeys "m"
Else
SendKeys "m"
End If
End Sub

http://cjoint.com/?lfwRpuT2Tp

JB


bonjour à tous
Est-il possible par vba de modifier la police du texte d'un commentaire
(gras, italique, couleur.....)
Merci
A+
Yan


Avatar
yan
Bonjour
Merci a vous 3
J'ai récuperer dans vos examples ce que j'avais besoin ( et que je ne
connaissais pas) à une proc en cours
ça marche
Encore merci
bonne journée
A+
Yan

"yan" a écrit dans le message de news:
454e389f$0$5110$
bonjour à tous
Est-il possible par vba de modifier la police du texte d'un commentaire
(gras, italique, couleur.....)
Merci
A+
Yan