XL 2019 VBA Excel : Commentaire en gras

OuiOuiNonNon

XLDnaute Nouveau
Bonjour, j'aimerais que le dernier caractère de mon commentaire soit en gras mais je ne sais pas comment faire. Merci d'avance :)
 
Solution
Pas simple à trouver...
VB:
Sub Test()
    If Not [C6].Comment Is Nothing Then [C6].Comment.Delete
    [C6].AddComment
    [C6].Comment.Visible = True
    [C6].Comment.Text Text:="Exemple:" & Chr(10) & "Commentaire X en gras: X"
    Call FormatCommentaireDernierCaractèresGras([C6])
End Sub

Sub FormatCommentaireDernierCaractèresGras(Cellule As Range)
    Dim Lg As Integer
    
    If Cellule.Comment Is Nothing Then Exit Sub
    
    Lg = Len(Cellule.Comment.Text)
    
    With Cellule.Comment.Shape.TextFrame
        '.Characters.Font.Size = 11
        '.Characters.Font.Color = RGB(255, 0, 0)
        '.Characters(Start:=1, Length:=Lg).Font.Bold = False
        .Characters(Start:=Lg, Length:=1).Font.Bold = True
    End With
End Sub

Dudu2

XLDnaute Barbatruc
Pas simple à trouver...
VB:
Sub Test()
    If Not [C6].Comment Is Nothing Then [C6].Comment.Delete
    [C6].AddComment
    [C6].Comment.Visible = True
    [C6].Comment.Text Text:="Exemple:" & Chr(10) & "Commentaire X en gras: X"
    Call FormatCommentaireDernierCaractèresGras([C6])
End Sub

Sub FormatCommentaireDernierCaractèresGras(Cellule As Range)
    Dim Lg As Integer
    
    If Cellule.Comment Is Nothing Then Exit Sub
    
    Lg = Len(Cellule.Comment.Text)
    
    With Cellule.Comment.Shape.TextFrame
        '.Characters.Font.Size = 11
        '.Characters.Font.Color = RGB(255, 0, 0)
        '.Characters(Start:=1, Length:=Lg).Font.Bold = False
        .Characters(Start:=Lg, Length:=1).Font.Bold = True
    End With
End Sub
 
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
312 111
Messages
2 085 392
Membres
102 882
dernier inscrit
Sultan94