如何使用VBA设置Word尾注表格第三列字体为隐藏格式
Word VBA 设置尾注区域表格第三列为隐藏字体的实现方法
直接在现有代码的表格操作逻辑中,新增对第三列范围的字体隐藏属性赋值即可,Word VBA 中字体隐藏格式由Font.Hidden属性控制,将该属性值设为True即可为目标区域应用隐藏字体效果。
修改后的完整代码如下:
Sub d_FormatTableEndNoteDemo2() Application.ScreenUpdating = False Dim Tbl As Table For Each Tbl In ActiveDocument.StoryRanges(wdEndnotesStory).Tables With Tbl .AllowAutoFit = False .Rows.Alignment = wdAlignRowCenter .Rows.Height = CentimetersToPoints(0.6) .Range.Cells.VerticalAlignment = wdCellAlignVerticalTop .Range.ParagraphFormat.Alignment = wdAlignParagraphLeft .Columns(1).Width = CentimetersToPoints(1#) .Columns(2).Width = CentimetersToPoints(5#) .Columns(3).Width = CentimetersToPoints(11#) ' 设置第三列字体为隐藏格式 .Columns(3).Range.Font.Hidden = True End With Next Application.ScreenUpdating = True End Sub
注意事项:如果尾注内的表格存在跨列合并单元格,直接引用
Columns(3)会触发运行时错误,这类场景需要逐行遍历单元格、判断所属列位置后再设置隐藏属性;无合并单元格的标准三列表格可直接运行上述代码。
内容的提问来源于stack exchange,提问作者New Bee
相关产品推荐
相关产品推荐

