Sub 修改样式模板()
With Selection.Font
'字体设置 (字体 字号 加粗)
.NameFarEast = "宋体" '设置中文字体
.NameAscii = "Times New Roman" '设置英文字体
.Size = 18 '字号,请输入对应数字
.Bold = 1 '加粗为1,不加粗为0
End With
With Selection.ParagraphFormat
'对齐方式
.Alignment = wdAlignParagraphCenter '居中对齐,看代码最后的Center
.Alignment = wdAlignParagraphLeft '左对齐
.Alignment = wdAlignParagraphRight '右对齐
.Alignment = wdAlignParagraphDistribute '分散对齐
.Alignment = wdAlignParagraphJustify '两端对齐
'大纲级别,正文级别,大纲级别1-9,只设置章为1,节为2,条为3
.OutlineLevel = wdOutlineLevelBodyText '正文文本
.OutlineLevel = wdOutlineLevel1 '章标题
.OutlineLevel = wdOutlineLevel2 '节标题
.OutlineLevel = wdOutlineLevel3 '条标题
'首行缩进2字符
.CharacterUnitFirstLineIndent = 2
'段前段后
.LineUnitBefore = 0.8 '段前行距为0.8行
.LineUnitAfter = 0.5 '段后行距为0.5行
.SpaceBefore = 32 '段前行距为32磅
.SpaceAfter = 23 '段前行距为23磅
'行间距 (固定值)
.LineSpacingRule = wdLineSpaceExactly '行间距设定为固定值23
.LineSpacing = 23 '行间距设定为固定值23
.LineSpacingRule = wdLineSpaceSingle '单倍行距
.LineSpacingRule = wdLineSpace1pt5 '1.5倍行距
.LineSpacingRule = wdLineSpaceDouble '2倍行距
.LineSpacingRule = wdLineSpaceMultiple '多倍行距
.LineSpacingRule = wdLineSpaceAtLeast '行间距设定为最小行距值23
.LineSpacing = 23 '行间距设定为最小行距值23
End With
End Sub
Sub 页边距单位厘米()
Dim i, j, m, n
'修改部分
i = 页边距单位厘米上边距 '上边距,单位厘米
j = 页边距单位厘米下边距 '下边距,单位厘米
m = 页边距单位厘米左边距 '下边距,单位厘米
n = 页边距单位厘米右边距 '左边距,单位厘米
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(i)
.BottomMargin = CentimetersToPoints(j)
.LeftMargin = CentimetersToPoints(m)
.RightMargin = CentimetersToPoints(n)
End With
End Sub
Sub 全选()
Selection.WholeStory
End Sub
Sub 清除所有格式()
Selection.ClearFormatting
With Selection.Font
'字体设置 (字体 字号 加粗)
.NameFarEast = "宋体"
.NameAscii = "Times New Roman"
.Size = 12 '字号,请输入对应数字
.Bold = 0 '加粗为1,不加粗为0
End With
'取消缩进
With Selection.ParagraphFormat
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.FirstLineIndent = CentimetersToPoints(0)
.Alignment = wdAlignParagraphJustify
.LineSpacingRule = wdLineSpaceExactly
.LineSpacing = 23 '行间距设定为固定值23
End With
End Sub
Sub 插入分页符()
Selection.InsertBreak Type:=0
End Sub
Sub 删除空格()
Dim myRange As Range
'选择区域为插入点
If Selection.Type = wdSelectionIP Then
MsgBox "未选定区域!"
Else
Set myRange = Selection.Range
myRange.Find.Execute FindText:=" ", replacewith:="", Replace:=wdReplaceAll
MsgBox "空格删除完毕!"
End If
End Sub
Sub 删除空行()
Dim myRange As Range
'选择区域为插入点
If Selection.Type = wdSelectionIP Then
MsgBox "未选定区域!"
Else
Set myRange = Selection.Range
myRange.Find.Execute FindText:="^p^p", replacewith:="^p", Replace:=wdReplaceAll
MsgBox "空行删除完毕!"
End If
End Sub
Sub 删除换行符()
Dim myRange As Range
'选择区域为插入点
If Selection.Type = wdSelectionIP Then
MsgBox "未选定区域!"
Else
Set myRange = Selection.Range
myRange.Find.Execute FindText:="^p", replacewith:="", Replace:=wdReplaceAll
MsgBox "换行符删除完毕!"
End If
End Sub
Sub 插入公式编号()
'
'插入公式测试 宏
'
'
With CaptionLabels("公式")
.NumberStyle = wdCaptionNumberStyleArabic
.IncludeChapterNumber = True
.ChapterStyleLevel = 1
.Separator = wdSeparatorPeriod
End With
Selection.InsertCaption Label:="公式", TitleAutoText:="InsertCaption1", _
Title:="", Position:=wdCaptionPositionBelow, ExcludeLabel:=1
End Sub
Sub 插入图编号()
Selection.InsertCaption Label:="图", TitleAutoText:="InsertCaption1", Title _
:="", Position:=wdCaptionPositionBelow, ExcludeLabel:=0
End Sub
Sub 插入表编号()
Selection.InsertCaption Label:="表", TitleAutoText:="InsertCaption1", Title _
:="", Position:=wdCaptionPositionBelow, ExcludeLabel:=0
End Sub
Sub 单个三线表与内容()
'三线表格式设置
Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
'上边框1.5磅
Options.DefaultBorderLineWidth = wdLineWidth150pt
With Selection.Borders(wdBorderTop)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
'上边框1.5磅
Options.DefaultBorderLineWidth = wdLineWidth150pt
With Selection.Borders(wdBorderBottom)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
'中间边框0.5磅
Options.DefaultBorderLineWidth = wdLineWidth050pt
With Selection.Rows(1).Borders(wdBorderBottom) '第一行的底边框
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Font
.NameFarEast = "表格内容中文字体"
.NameAscii = "表格内容英文字体"
.Size = 表格内容大小 '字号,请输入对应数字
.Bold = 表格内容粗细 '加粗为1,不加粗为0
End With
With Selection.ParagraphFormat
.Alignment = 表格内容对齐 '两端对齐
'大纲级别,正文级别,大纲级别1-9,只设置章为1,节为2,条为3
.OutlineLevel = 表格内容大纲级别 '章标题
'首行缩进2字符
.CharacterUnitFirstLineIndent = 表格内容首行缩进字符
'段前段后
.LineUnitBefore = 表格内容段前行距单位行 '段前为0.8行
.LineUnitAfter = 表格内容段后行距单位行 '段后为0.5行
End With
Dim Choice As String '定义Choice
评论0