Advertisement
Xyberviri

Format powerpoint table borders to white

Jun 28th, 2017
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' cobbled together between these two scripts
  2. ' https://stackoverflow.com/questions/31821984/formatting-table-in-powerpoint-macro
  3. ' http://skp.mvps.org/pptxp009.htm
  4.  
  5. Option Explicit
  6. Sub format()
  7.  
  8. Dim s As Slide
  9. Dim oSh As Shape
  10. Dim oTbl As Table
  11. Dim lRow As Long
  12. Dim lCol As Long
  13.  
  14. For Each s In ActivePresentation.Slides
  15. ' If you choose Debug | Compile, this next line fails
  16. ' There's no such property as .Table
  17. ' With s.Shapes.Table
  18.    For Each oSh In s.Shapes
  19.         If oSh.HasTable Then
  20.             Set oTbl = oSh.Table
  21.             Call SetTableBorder(oTbl)
  22.             ' For lRow = 1 To oTbl.Rows.Count
  23.                ' For lCol = 1 To oTbl.Columns.Count
  24.                    ' With oTbl.Cell(lRow, lCol).Shape.TextFrame.TextRange
  25.                        ' .Font.Name = "Arial"
  26.                        ' .Font.Size = 30
  27.                    ' End With
  28.                ' Next
  29.            ' Next
  30.        End If
  31.     Next    ' Shape
  32. Next s
  33.  
  34. End Sub
  35.  
  36. ' Option Explicit
  37. ' Sub HowToUseIt()
  38. ' Call SetTableBorder(ActivePresentation.Slides(1).Shapes(1).Table)
  39. ' End Sub
  40.  
  41. Sub SetTableBorder(oTable As Table)
  42. Dim I As Integer
  43. With oTable
  44.     For I = 1 To .Rows.Count
  45.         With .Rows(I).Cells(1).Borders(ppBorderLeft)
  46.             .ForeColor.RGB = RGB(255, 255, 255)
  47.             .Weight = 5
  48.         End With
  49.         With .Rows(I).Cells(.Rows(I).Cells.Count).Borders(ppBorderRight)
  50.             .ForeColor.RGB = RGB(255, 255, 255)
  51.             .Weight = 5
  52.         End With
  53.     Next I
  54.     For I = 1 To .Columns.Count
  55.         With .Columns(I).Cells(1).Borders(ppBorderTop)
  56.             .ForeColor.RGB = RGB(255, 255, 255)
  57.             .Weight = 5
  58.         End With
  59.         With .Columns(I).Cells(.Columns(I).Cells.Count).Borders(ppBorderBottom)
  60.             .ForeColor.RGB = RGB(255, 255, 255)
  61.             .Weight = 5
  62.         End With
  63.     Next I
  64. End With
  65. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement