| Blog信息 |
|
blog名称:注册会计师(注会)练习软件 日志总数:398 评论数量:116 留言数量:27 访问次数:3279718 建立时间:2005年6月6日 |

| |
|
[delpih编程]利用vba统一word文档中所有的表格风格(原创,加缩进便于浏览) 软件技术
吕向阳 发表于 2010/11/7 20:16:00 |
| 在审计实践中,财务报表附注这个文档往往含有数十个大小不一的表格。自己在做附注时有可能要改变一下风格,整个文件中全部表格重新调整过来,可能要几个小时或更多的时间,这时vba可方便助你改变表格风格,可能只是几十秒,所有表格调整一致,干净清爽。下面是代码,您可按需要设置每行高度,表格颜色,Sub change_table_style() Dim atable If ActiveDocument.Tables.Count >= 1 Then For Each atable In ActiveDocument.Tables'对所有表格进行循环 atable.Select'将所有的表格调整到左对齐,这样看起来整体协调 Selection.Rows.HeightRule = wdRowHeightAtLeast'调整每行高度到0.65cm,这个您自个定 Selection.Rows.Alignment = wdAlignRowLeft atable.Rows.Height = CentimetersToPoints(0.65)'这个调整表格中每个单元格是垂直方向居中对齐 Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter'调整表格中的字大小为9# Selection.Font.Size = 9'下面不解释了,是表格每条边线的线条与颜色 Options.DefaultBorderLineWidth = wdLineWidth050pt Options.DefaultBorderLineWidth = wdLineWidth075pt With Options .DefaultBorderLineStyle = wdLineStyleSingle .DefaultBorderLineWidth = wdLineWidth075pt .DefaultBorderColor = wdColorAutomatic End With With Selection.Borders(wdBorderHorizontal) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With With Selection.Borders(wdBorderVertical) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With With Selection.Borders(wdBorderBottom) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With With Selection.Borders(wdBorderTop) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With Options.DefaultBorderLineWidth = wdLineWidth050pt With Options .DefaultBorderLineStyle = wdLineStyleDot .DefaultBorderLineWidth = wdLineWidth050pt .DefaultBorderColor = wdColorAutomatic End With With Selection.Borders(wdBorderHorizontal) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With With Selection.Borders(wdBorderVertical) .LineStyle = Options.DefaultBorderLineStyle .LineWidth = Options.DefaultBorderLineWidth .Color = Options.DefaultBorderColor End With'表格往左调整多少距离,这样对宽表格有利一些,根据需要调整 atable.Rows.SetLeftIndent LeftIndent:=-0.2, RulerStyle:= _ wdAdjustNone Next atable End If MsgBox "over"End Sub |
|
|