对Word文档中所有表格进行格式处理
发布时间:2018-07-01 18:51:32
发布时间:2018-07-01 18:51:32
对Word文档中所有表格进行格式处理
对Word文档中所有表格进行格式处理,做一个按钮:循环本文档的所有表,格式化表格:使边框的上、下边界线为单线1.5磅;无左右边界线,中间分隔线为单线0.75磅。
Private Sub CommandButton1_Click()Dim Myshe As Table '声明变量为表格For Each Myshe In ThisDocument.Tables '在文档中表格集合内循环 Myshe.PreferredWidthType = wdPreferredWidthPercent '设置Word 以窗口宽度的百分比来表示宽度 Myshe.PreferredWidth = 100 '表格的宽度设置为窗口宽度的100% Myshe.Borders.InsideLineStyle = wdLineStyleSingle '设置指定对象的内部边框:单线 Myshe.Borders.Enable = True '设置指定对象的边框格式:默认线型 Myshe.Borders.InsideLineWidth = wdLineWidth075pt '设置指定对象的内部边框宽度:0.75 Myshe.Borders(2).LineStyle = wdLineStyleNone '设置指定对象的右边框:无 Myshe.Borders(4).LineStyle = wdLineStyleNone '设置指定对象的左边框:无 Myshe.Borders(1).LineWidth = wdLineWidth150pt '设置指定对象的上边框宽度:1.50 Myshe.Borders(3).LineWidth = wdLineWidth150pt '设置指定对象的下边框宽度:1.50NextEnd Sub