删除powerpoint中的表格边框

时间:2016-01-08 18:54:30

标签: vba powerpoint powerpoint-vba

代码成功删除了表格边框,在屏幕上显示正常。

在打印或打印预览时,它会显示一些表格边框。如何解决?

 Sub Tableformatting ()
    Dim r As Long, c As Long
    Dim t As Table
      Set t = ActiveWindow.Selection.ShapeRange.Table
            For r = 1 To t.Rows.Count
            For c = 1 To t.Columns.Count
                With t.Cell(r, c)

                    .Borders(ppBorderTop).Transparency = 0
                    .Borders(ppBorderTop).Weight = 0
                    .Borders(ppBorderBottom).Transparency = 0
                    .Borders(ppBorderBottom).Weight = 0
                    .Borders(ppBorderLeft).Transparency = 0
                    .Borders(ppBorderLeft).Weight = 0

                    .Borders(ppBorderRight).Transparency = 0
                    .Borders(ppBorderRight).Weight = 0

                End With
            Next c
        Next r
    End Sub

1 个答案:

答案 0 :(得分:2)

尝试使用

Sub Tableformatting()
Dim r As Long, c As Long
Dim t As Table

Set t = ActiveWindow.Selection.ShapeRange.Table

For r = 1 To t.Rows.Count
    For c = 1 To t.Columns.Count
        With t.Cell(r, c)
            .Borders(ppBorderTop).Transparency = 1
            .Borders(ppBorderBottom).Transparency = 1
            .Borders(ppBorderLeft).Transparency = 1
            .Borders(ppBorderRight).Transparency = 1
        End With
    Next c
Next r
End Sub

出于某种原因。透明度= 0仅适用于积极看到的内容,但。透明度= 1适用于您要求的所有内容。这可能是微软的一个错误,因为我不明白为什么这个方法或.Borders.Visible = msoFalse不适用于打印/打印预览。

无论哪种方式,我希望这有帮助!