PDA

View Full Version : [SOLVED:] Making table fonts all black in below code



RayKay
01-31-2019, 08:28 AM
Hi John

I have code below, and I've tried EVERYTHING for the past few hours so it changes any fonts to black. Sounds simple, but impossible!

Working Code: (but doesn't change any fonts to black)

Public Sub TableLines()


Dim tbl As Table
Dim iCol As Integer
Dim iRow As Integer
Dim I As Integer
Set tbl = ActiveWindow.Selection.ShapeRange(1).Table
' hide selected borders
Call CommandBars.ExecuteMso("BorderNone")
DoEvents
'exit if no selected table
If err.Number <> 0 Then Exit Sub
For iRow = 1 To tbl.Rows.Count
For iCol = 1 To tbl.Columns.Count
If tbl.Cell(iRow, iCol).Selected Then
For I = 1 To 3 Step 2
With tbl.Cell(iRow, iCol)
.Borders(I).visible = msoTrue
.Borders(I).ForeColor.RGB = RGB(180, 180, 180)
.Borders(I).Weight = 0.75
End With
Next I
End If
Next iCol
Next iRow


End Sub

Code I have tried to use (to only affect the one table for the above code):

With ActivePresentation.Slides(1).Shapes(1)
With .TextFrame.TextRange.Font
.Name = "Arial"
.Color.RGB = RGB(0, 0, 0)
End With

Any chance you can help please? I know you're busy, and a great man for sharing your wisdom, thank you.

RayKay
01-31-2019, 08:38 AM
Hi John, and visitors

I worked it out! Finally, thanks to reading code you'd published on here. I used this bit and added it near the start:

Set otbl = ActiveWindow.Selection.ShapeRange(1).Table
For X = 1 To otbl.Columns.Count
For Y = 1 To otbl.Rows.Count
With otbl.Cell(Y, X)
If .Selected Then
.Shape.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Shape.TextFrame2.TextRange.Font.Size = 12
.Shape.TextFrame2.TextRange.Font.Name = "Arial"
.Shape.TextFrame2.TextRange.Font.Bold = msoFalse
End If
End With
Next 'y
Next 'x

:thumb

John Wilson
01-31-2019, 10:40 AM
That's good. It is always better to learn and do it yourself!