XL 2016 Mettre des balises html autour d'un text

Don pépé

XLDnaute Occasionnel
Bonjour,
J'ai un textbox et je voudrais ajouter une balise html autour du texte sélectionner dans se textbox multiligne.

je sais comment mettre ma balise avant le texte ou apres dans la textbox avec
VB:
'Souligner
Private Sub Label3_Click()
Dim Rv
  'Si le contrôle actif est un TextBox "SetFocus"
    If TypeName(Me.ActiveControl) = "TextBox" Then
        Rv = Me.ActiveControl.Value
        Me.ActiveControl.Value = "<u></u>" & Rv
    Else
        MsgBox "Vous devez sélectionner une section", vbCritical, "Erreur"
    End If
End Sub

mais autour du text sélectionner je n'y arrive pas

help me please

merci a vous
 
Dernière édition:

Dranreb

XLDnaute Barbatruc
Comme ça ça semble marcher :
VB:
Private Sub Label3_Click()
Dim TBx As MSForms.TextBox, P&, L&
On Error Resume Next
Set TBx = Me.ActiveControl
If Err Then Exit Sub
P = TBx.SelStart
L = TBx.SelLength
TBx.Text = Left$(TBx.Text, P) & "<u>" & Mid$(TBx.Text, _
   P + 1, L) & "</u>" & Mid$(TBx.Text, P + 1 + L)
End Sub
 

Statistiques des forums

Discussions
312 334
Messages
2 087 381
Membres
103 530
dernier inscrit
dieubrice