手机
当前位置:查字典教程网 >软件教程 >办公软件 >如何设置Word表格的VBA代码
如何设置Word表格的VBA代码
摘要:VBA代码设置Word表格属性。DimiAsTable,NAsIntegerOnErrorResumeNext’忽略错误Appl...

VBA代码设置Word表格属性。

Dim i As Table, N As Integer

On Error Resume Next ’忽略错误

Application.ScreenUpdating = False ’关闭屏幕更新

For Each i In ActiveDocument.Tables ’在表格中循环

With i

.Style = "列表型 4" ’将所有表格设置为"列表型4"的样式

With .Borders ‘边框

.InsideLineStyle = wdLineStyleSingle ’设置内部边框线条

End With

With .Rows(1).Borders(wdBorderBottom) ‘第一行的底边框

.LineStyle = wdLineStyleDouble ‘双线型

.LineWidth = wdLineWidth050pt

.Color = wdColorAutomatic

End With

If .Rows.Count > 1 Then ’ 如果表格行数大于1

If Len(.Cell(2, 1).Range) <= 2 Then ’如果第二行第一列不为空

With .Rows(2).Shading ’设置底纹

.Texture = wdTextureNone ’无底底纹

.ForegroundPatternColor = wdColorAutomatic

.BackgroundPatternColor = wdColorGray125

End With

End If

End If

For N = 2 To .Columns.Count ’从第二列到最后一列

.Columns(N).Select ’单元格对齐方式为中部居中

Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter

Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter

Next N

End With

Next i

Application.ScreenUpdating = True

以上的代码功能为:表格集合中的循环与对单元格边框的设置。

【如何设置Word表格的VBA代码】相关文章:

如何设置Word2010搜索结果以黄色高亮背景显示

如何利用WPS表格将姓名转换为姓名代码

如何使用Word2003制作表格的详细步骤

Word的书籍折页是什么如何设置Word的书籍折页

如何设置Word2010不保存最近浏览的文档

如何设置Word表格的边框线样式和颜色

如何在Word2007中插入带样式的页码

如何设置excel中打印相同表头

如何频繁地在Word 2007中添加表格的图文介绍

如何修改Word2010文档中的默认样式

精品推荐
分类导航