Consulting

Results 1 to 4 of 4

Thread: Table to be font size

  1. #1
    VBAX Contributor
    Joined
    Dec 2018
    Location
    South London
    Posts
    115
    Location

    Table to be font size

    Hi John

    I'm hoping you, or anyone, can help me with the blue code below.
    The VBA puts borders between table rows that are selected.

    The aim was for fonts to become Arial Size 12 - but it only updates text and not bulleted text.
    Is it possible to change bulleted text too?

    Thank you.



    Public Sub TableDividerLines()


    Dim tbl As Table
    Dim iCol As Integer
    Dim iRow As Integer
    Dim I As Integer
    On Error GoTo err
    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
    .ForeColor.RGB = RGB(180, 180, 180)
    .Weight = 0.75


    Dim oShp As Shape
    Dim oTbl As Table
    Dim K As Long
    Dim J As Long
    Set oShp = ActiveWindow.Selection.ShapeRange(1)
    Set oTbl = oShp.Table
    For K = 1 To oTbl.Columns.Count
    For J = 1 To oTbl.Rows.Count
    oTbl.Cell(I, J).Shape.TextFrame.TextRange.Font.Name = "Arial"
    oTbl.Cell(I, J).Shape.TextFrame.TextRange.Font.Size = 12
    Next
    Next


    End With
    Next I
    End If
    Next iCol
    Next iRow
    Exit Sub ' usual exit
    err: 'error
    MsgBox "Please select table rows / cells and try again"
    End Sub

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    You have the outer (Rows) loop and the inner loop the wrong way around.

    Dim oShp As Shape
    Dim oTbl As Table
    Dim R As Integer
    Dim C As Integer
    Set oShp = ActiveWindow.Selection.ShapeRange(1)
    Set oTbl = oShp.Table
    For R = 1 To oTbl.Rows.Count ' outer loop is Rows
    For C = 1 To oTbl.Columns.Count 'Inner is Columns
    oTbl.Cell(R, C).Shape.TextFrame.TextRange.Font.Name = "Arial"
    oTbl.Cell(R, C).Shape.TextFrame.TextRange.Font.Size = 12
    Next
    Next
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Contributor
    Joined
    Dec 2018
    Location
    South London
    Posts
    115
    Location

    Thank you!

    Thanks John. You're the most intelligent person I've ever crossed paths with.
    Thank you!

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    You haven't met my wife then!
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •