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

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