2024年5月27日发(作者:)

Sub 宏表格排版() '开始编

辑宏

'第八部分 设置表格边框和底纹

(1).Select '选中表格

With (1) '在选中的表格中操作

.Borders(wdBorderLeft).LineStyle = wdLineStyleNone '左边线无

.Borders(wdBorderRight).LineStyle = wdLineStyleNone '右边线无

With .Borders(wdBorderTop) '选择上边线

.LineStyle = wdLineStyleSingle '选择单线

.LineWidth = wdLineWidth150pt '选择1.5磅

.Color = wdColorAutomatic '颜色自动

End With

With .Borders(wdBorderBottom) '选择底边线

.LineStyle = wdLineStyleSingle

.LineWidth = wdLineWidth150pt

.Color = wdColorAutomatic

End With

With .Borders(wdBorderHorizontal) '选择中间水平线

.LineStyle = wdLineStyleDot '选择细虚线

.LineWidth = wdLineWidth050pt '选择0.5磅

.Color = wdColorAutomatic '颜色选自动

End With

With .Borders(wdBorderVertical) '选择中间垂直线

.LineStyle = wdLineStyleDot

.LineWidth = wdLineWidth050pt

.Color = wdColorAutomatic

End With

.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone

.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone

. = False '边界无填充

End With

With Options

.DefaultBorderLineStyle = wdLineStyleDot

.DefaultBorderLineWidth = wdLineWidth050pt

.DefaultBorderColor = wdColorAutomatic

End With

'第一部分 设置首列

(1).Select '选中表格

y Unit:=wdLine '选择第一单元格

Column '选中首列

Cell '选中首列单元格

ent = wdAlignParagraphJustify '水平向前

redWidthType = wdPreferredWidthPoints '设置首列度量单位为

厘米

redWidth = CentimetersToPoints(5) '设置首列宽度为5厘米

'第七部分 设置首行居中 重复标题行

(1).Select '选中表5格

y Unit:=wdLine '选择第一单元格

Row '选中首行

gFormat = True '重复标题行

ent = wdAlignParagraphCenter '首行水平居中

'第一部分 设置段落

(1).Select

With aphFormat

.LeftIndent = CentimetersToPoints(0) '左缩进0字符

.RightIndent = CentimetersToPoints(0.1) '右缩进0字符

.SpaceBefore = 0 '间距段前0行

.SpaceBeforeAuto = False

.SpaceAfter = 0 '间距段后0行

.SpaceAfterAuto = False

.LineSpacingRule = wdLineSpaceMultiple '设置多倍行距

.LineSpacing = LinesToPoints(1.15) '设置行距1.15倍

.WidowControl = False

.KeepWithNext = False

.KeepTogether = False

.PageBreakBefore = False

.NoLineNumber = False

.Hyphenation = True

.FirstLineIndent = CentimetersToPoints(0)

.OutlineLevel = wdOutlineLevelBodyText

.CharacterUnitLeftIndent = 0

.CharacterUnitRightIndent = 0

.CharacterUnitFirstLineIndent = 0

.LineUnitBefore = 0

.LineUnitAfter = 0

.MirrorIndents = False

.TextboxTightWrap = wdTightNone

.AutoAdjustRightIndent = False

.DisableLineHeightGrid = True

.FarEastLineBreakControl = True

.WordWrap = True '自动换行

.HangingPunctuation = True