具体要求:第一段即文档题目,去除段前空格,字体为“黑体”,字号为“小二”,加粗,居中对齐,请用VBA代码,千万不要用菜单命令操作。正文格式不变。
高手!
能不能在您提供的代码后再加上正文设置代码?
正文(即第二段以后)格式:每段首行缩进2字符,字体为“仿宋-GB2312",字号为“小三”,每段首行是:一 二三四五六七八九十或(一)(二)(三)(四)(五)(六)(七)(八)(九)(十)或1 2 3 4 5 6 7 8 9 10等字符要加粗
万分期待
Sub test()
With Application.ActiveDocument
Dim i, pcount As Integer, astr As String
pcount = .Paragraphs.Count
For i = 2 To pcount
astr = Left(.Paragraphs(i).Range.Text, 1)
Select Case astr
Case "1" To "9", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"
.Paragraphs(i).Range.Select
Selection.MoveLeft (1)
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Font.Bold = True
Case "("
If Mid(.Paragraphs(i).Range.Text, 3, 1) = ")" Then
Select Case Mid(ActiveDocument.Paragraphs(i).Range.Text, 2, 1)
Case "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"
.Paragraphs(i).Range.Select
Selection.MoveLeft (1)
Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend
Selection.Font.Bold = True
End Select
End If
End Select
Next
.Paragraphs(2).Range.Select
End With
With Selection
.MoveLeft (1)
.EndKey Unit:=wdStory, Extend:=wdExtend
.Font.Size = 15
.ParagraphFormat.CharacterUnitFirstLineIndent = 2
.Font.Name = "仿宋-GB2312"
End With
End Sub
您编写的题目格式代码与正文格式代码分开是可以用的,我需要把两段代码合在一起,敬请赐教,十分感谢
追答去 VBE 里面导入即可。