Mettre en gras plusieurs partie d'un texte dans une zone texte
Résolu
bassmart
Messages postés
281
Date d'inscription
Statut
Membre
Dernière intervention
-
bassmart Messages postés 281 Date d'inscription Statut Membre Dernière intervention -
bassmart Messages postés 281 Date d'inscription Statut Membre Dernière intervention -
A voir également:
- Vba mettre en gras une partie de texte
- Mettre en gras sur whatsapp - Guide
- Transcription audio en texte word gratuit - Guide
- Mettre un texte en majuscule - Guide
- Excel cellule couleur si condition texte - Guide
- Nouvelle partie pokemon x ✓ - Forum DS
2 réponses
Bonjour
Length=indique le nombre de caractères retenus à partir du premier indiqué par la valeur de "Start". Dans votre cas, vous prenez 22 caractères à partir du 21ème. Remplacez Length:=22 par Length:=4 pour les 4 caractères de "Site".
Mais vous pouvez remplacez les 2 paragraphes suivants
par
A tester
Cdlt
Length=indique le nombre de caractères retenus à partir du premier indiqué par la valeur de "Start". Dans votre cas, vous prenez 22 caractères à partir du 21ème. Remplacez Length:=22 par Length:=4 pour les 4 caractères de "Site".
With selection.Characters(Start:=21, Length:=4).Font
Mais vous pouvez remplacez les 2 paragraphes suivants
With selection.Characters(Start:=1, Length:=20).Font .Name = "Arial" .FontStyle = "Bold" .Size = 14 .ColorIndex = xlAutomatic End With With selection.Characters(Start:=21, Length:=22).Font' Ici ça ne fonctionne pas le mots "Site" et tout ce qui suit est en gras .Name = "Arial" .FontStyle = "Bold" .Size = 12 .ColorIndex = xlAutomatic End With
par
With selection.Characters(Start:=1, Length:=25).Font .Name = "Arial" .FontStyle = "Bold" .Size = 14 .ColorIndex = xlAutomatic End With
A tester
Cdlt
Bonjour
Essayez ceci
Essayez ceci
Sub zone_texte() Dim Phrase, PosSondage, PosElevation Phrase = "MINISTÈRE DES TRANSPORT - SUIVI PIÉZOMÉTRIQUE" & vbCrLf & vbCr & "SITE: " & UserForm2.TextBox1 & Space(45) & "SONDAGE: " & UserForm2.TextBox2 & Space(45) & "ÉLÉVATION T.N: " & UserForm2.TextBox3 PosSondage = InStr(1, Phrase, "SONDAGE", 1) PosElevation = InStr(1, Phrase, "ÉLÉVATION T.N", 1) ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 10, 600, 70).Select With Selection .Name = "Ma_zone" .ShapeRange.Fill.Visible = msoTrue .ShapeRange.Fill.Solid .ShapeRange.Fill.Transparency = 0# .ShapeRange.Line.Weight = 0.75 .ShapeRange.Line.DashStyle = msoLineSolid .ShapeRange.Line.Style = msoLineSingle .ShapeRange.Line.Transparency = 0# .ShapeRange.Line.Visible = msoTrue .ShapeRange.Line.ForeColor.SchemeColor = 64 .ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255) .Characters.Text = Phrase .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter End With With Selection.Characters(Start:=1, Length:=45).Font .Name = "Arial" .FontStyle = "Bold" .Size = 14 .ColorIndex = xlAutomatic End With With Selection.Characters(Start:=PosSondage, Length:=7).Font .Name = "Arial" .FontStyle = "Bold" .Size = 12 .ColorIndex = xlAutomatic End With With Selection.Characters(Start:=103, Length:=8).Font .Name = "Arial" .FontStyle = "Bold" .Size = 12 .ColorIndex = xlAutomatic End With With Selection.Characters(Start:=PosElevation, Length:=14).Font .Name = "Arial" .FontStyle = "Bold" .Size = 12 .ColorIndex = xlAutomatic End With End SubCdlt
J'avais mal compris la fonction.
Merci!
Le problème c'est que j'insère du texte avec des textbox via un userform et les mots insérés ne sont pas toujours de la même longueur. Donc au final, mes titres (SONDAGE et ÉLÉVATION T.N ne sont pas toujours en gras comme voulu.
Il y a t'il un autre solution?
Voici mon code complet:
Merci pour votre aide!