Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Style de Font (Gras)

1 réponse
Avatar
Guy72
Bonsoir,
Quelqu'un peut-il me dire pourquoi, je n'arrie pas àa avoir le caractère
gras ?
Merci de votre aide.

Sub Rectangle()
For Each c In Selection
Rectangle_1 c
Next c
End Sub

Sub Rectangle_1(c)
On Error Resume Next
ActiveSheet.Shapes(c.Address & "1").Delete
With ActiveSheet.Shapes.AddShape(Type:=msoShapeRectangle, _
Left:=c.Left, Top:=c.Top + 1, _
Width:=c.Width, Height:=c.Height)
.Fill.ForeColor.RGB = RGB(255, 255, 204)
.Line.Visible = msoTrue
.Name = c.Address & "1"
.OLEFormat.Object.Characters.Text = "Texte"
.OLEFormat.Object.Characters.Font.Size = 10
.OLEFormat.Object.Name = "Arial"
.OLEFormat.Object.FontStyle = "Gras"
.OLEFormat.Object.HorizontalAlignment = xlCenter
.OLEFormat.Object.VerticalAlignment = xlCenter
.OLEFormat.Object.ReadingOrder = xlContext
.OLEFormat.Object.Orientation = xlHorizontal
End With
End Sub

--
Cordialement
Guy

1 réponse

Avatar
Guy72
Bonjour et merci
--
Cordialement
Guy

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

A ) On Error Resume Next
Avant d'utiliser cette ligne de code, il faut tester son code
et s'assurer que lorsque toutes les conditions sont réunies
le code fait le travail. Lors des tests préliminaires, l'absence
de cette ligne de code va permettre à excel de t'indiquer qu'est-ce
qui est problématique dans ton code.
Tu te dois de savoir pourquoi tu utilises cette ligne de code sinon
comment savoir si ta procédure fonctionne bien ?

'--------------------------------
Sub Rectangle()
Dim C As Range
For Each C In Selection
Rectangle_1 C
Next C
End Sub
'--------------------------------
Sub Rectangle_1(Rg As Range)
On Error Resume Next
ActiveSheet.Shapes(Rg.Value & "1").Delete
With ActiveSheet.Shapes.AddShape(Type:=msoShapeRectangle, _
Left:=Rg.Left, Top:=Rg.Top + 1, _
Width:=Rg.Width, Height:=Rg.Height)
.Fill.ForeColor.RGB = RGB(255, 255, 204)
.Line.Visible = msoTrue
.Name = Rg.Address & "1"
With .OLEFormat.Object
With .Characters
.Text = "Texte"
.Font.Size = 10
.Font.Name = "Arial"
.Font.Bold = True
End With
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ReadingOrder = xlContext
.Orientation = xlHorizontal
End With
End With
End Sub
'--------------------------------




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

Bonsoir,
Quelqu'un peut-il me dire pourquoi, je n'arrie pas àa avoir le caractère
gras ?
Merci de votre aide.

Sub Rectangle()
For Each c In Selection
Rectangle_1 c
Next c
End Sub

Sub Rectangle_1(c)
On Error Resume Next
ActiveSheet.Shapes(c.Address & "1").Delete
With ActiveSheet.Shapes.AddShape(Type:=msoShapeRectangle, _
Left:=c.Left, Top:=c.Top + 1, _
Width:=c.Width, Height:=c.Height)
.Fill.ForeColor.RGB = RGB(255, 255, 204)
.Line.Visible = msoTrue
.Name = c.Address & "1"
.OLEFormat.Object.Characters.Text = "Texte"
.OLEFormat.Object.Characters.Font.Size = 10
.OLEFormat.Object.Name = "Arial"
.OLEFormat.Object.FontStyle = "Gras"
.OLEFormat.Object.HorizontalAlignment = xlCenter
.OLEFormat.Object.VerticalAlignment = xlCenter
.OLEFormat.Object.ReadingOrder = xlContext
.OLEFormat.Object.Orientation = xlHorizontal
End With
End Sub

--
Cordialement
Guy