Dim bContinue As Boolean F
|GWYw'%
C2VZE
~U+
Dim regEX As New RegExp yZ2,AR%
Dim paraCounter As Long '全局段落计数,仅在主程序中可读写,其它过程函数应为只读 #(A>yW702
L2:C6Sc
Dim LastTitle0String As String, LastTitle0No As Long lyT~>.?{
Dim LastTitle1String As String, LastTitle1No As Long ik]UzB
Dim LastTitle2String As String, LastTitle2No As Long 8Ej2JMc
Dim LastTitle3String As String, LastTitle3No As Long 2vur_`cV
Dim LastTitle4String As String, LastTitle4No As Long oo qNPLa
Dim LastTitle5String As String, LastTitle5No As Long )PwDP
Dim LastTabelString As String, LastTableNo As Long vbWX`skU
Dim LastFigureString As String, LastFigureNo As Long aH~
il!K
>sP;B5S
Dim strSeperator As String Ufk7%`
Z2ZS5a
Sub ConvertWidth(fTEXT As String, rText As String) DS^Q0 f
Selection.Find.ClearFormatting
d2(n3Xf
Selection.Find.Replacement.ClearFormatting QTDI^ZeuF
Selection.Find.Wrap = wdFindContinue 4v{gc/g
Me.txtStatus.Text = "转换全角数字字母" & fTEXT & "形式为半角" & rText *L!R4;u
bE
DoEvents ' E@D
Selection.Find.Execute findtext:=fTEXT, replacewith:=rText, Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue, MatchCase:=True )9*-Q%zc
End Sub ^yfT7050
5=$D~>-#
Sub ClearDomain() D]0#A|nF
With Selection.Find }X`K3sk2/z
.ClearFormatting
%++q+pa
.Replacement.ClearFormatting sPhh#VCw{
.Wrap = wdFindContinue S
5XFYQ
Me.txtStatus.Text = "清除所有域代码" @U9ov >E
DoEvents $DQMN
.Execute findtext:="^d", replacewith:="", Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue, MatchWildcards:=False #A|MNJ%m
End With w,P2_xk`
End Sub h;Bol
5zUD W?
Private Sub cmdCheck_Click() 'tdjPdw
bContinue = True X-%*`XG'
Dim NoSeries1(1 To 16) As String w ggl,+7
Dim NoSeries2(1 To 16) As String B EY}mR]
Dim NoSeries5(1 To 16) As String cL}g7D
Dim NoSeriesRM(1 To 16) As String _LS=O@s^
Dim paraTotal As Long, ParaText As String U2h?l
`nP
Dim ttString As String, ttNo As String d)
> if<o
a]Lr<i8#%
Dim ShapeCounter As Long, ShapeHeight As Long, ShapeWidth As Long 68D.Li
_ '}UNIL
Me.txtStatus.Visible = True )cvC9gt
Me.lbParaType.Visible = True [k.<x'#
Me.cmdCheck.Enabled = False VMNihx0FJ
P3:hGmk8|j
7N:,F9V<
p3-sEIw}Ru
7y60-6r
Dim ParaType As String, rText As String UrtN3icph
-yC},tK
Selection.WholeStory \:Nbl<9(9
Selection.NoProofing = True hxv/285B
.|rpj&>g
tm1 = Now ul:jn]S*
9SU;c l
ActiveWindow.View.Type = wdNormalView ;Z8K3p
ed617J
NoSeries1(1) = "一" !]"T`^5,Y
NoSeries1(2) = "二" /2YI!U@A
NoSeries1(3) = "三" 9iv!+(ni
NoSeries1(4) = "四" eQNYfWR
NoSeries1(5) = "五" kmuF*0Bjk
NoSeries1(6) = "六" 8L<Ol
NoSeries1(7) = "七" %II |;<
NoSeries1(8) = "八" w+JDu_9+A]
NoSeries1(9) = "九" tn}9(Oa)
NoSeries1(10) = "十" lT%o6qgT
NoSeries1(11) = "十一" .-o$IQsS
NoSeries1(12) = "十二" {%
;tN`{M
NoSeries1(13) = "十三" bclA+!1
NoSeries1(14) = "十四" R[9[lQ'vR
NoSeries1(15) = "十五" _kar5B$
NoSeries1(16) = "十六" DQE.;0ld
Gz
kf
NoSeries2(1) = "㈠" 6.k2,C4dT<
NoSeries2(2) = "㈡" +4@EJRC
NoSeries2(3) = "㈢" x&7!m
NoSeries2(4) = "㈣"
T%:}/@
NoSeries2(5) = "㈤" 1|Fukx<@J<
NoSeries2(6) = "㈥" Bq\%]2;eo{
NoSeries2(7) = "㈦" 76hi@7a
NoSeries2(8) = "㈧" h<}4mo_$
NoSeries2(9) = "㈨" Wx^L~[l
NoSeries2(10) = "㈩" Er%nSH^"
[rf.P'p%
NoSeries5(1) = "①" O6m}#?Ai/@
NoSeries5(1) = "②" k<AnTboa
NoSeries5(3) = "③" h>fY'r)DAx
NoSeries5(4) = "④" C`DTPoXN
NoSeries5(5) = "⑤" -()CgtSR
NoSeries5(6) = "⑥" f>Ij:b`Z2
NoSeries5(7) = "⑦" eE7+fMP{
NoSeries5(8) = "⑧" z;Kyg}
NoSeries5(9) = "⑨" oo/#]a
NoSeries5(10) = "⑩"
TT>;!nb
_RAPXU~ 6-
r% qgLP{v
NoSeriesRM(1) = "I" eO*FoN
NoSeriesRM(2) = "II" zHyM@*Gf(
NoSeriesRM(3) = "III" k/*r2 C
NoSeriesRM(4) = "IV" ] @IzJz"R
NoSeriesRM(5) = "V" o8Tt|Lxb$8
NoSeriesRM(6) = "VI" Of-l<Ks\
NoSeriesRM(7) = "VII" RU@`+6j+
NoSeriesRM(8) = "VIII" p6sXftk
NoSeriesRM(9) = "IX" oo<,hOv
NoSeriesRM(10) = "X" \`x$@s?
NoSeriesRM(11) = "XI" SkS
vu}
NoSeriesRM(12) = "XII"
rFGbp8(2
NoSeriesRM(13) = "XIII" yQ h":"$k
NoSeriesRM(14) = "XIV" XC~|{d
NoSeriesRM(15) = "XV" k|&@xEbS
NoSeriesRM(16) = "XVI" g#:?Ay-m
0*+i~g,Kl@
i = MsgBox("为了你的数据安全,请使用单独保存的文件副本进行本操作。" & vbCrLf & "确定继续进行吗?", vbYesNo) 0b4QcfB1[
[X;yJ $
If i = vbNo Then -MeGJX:^I
Exit Sub 'w&,3@Z
End If 3>-^/
`rQA9;Tn2
If Me.chkSuper.Value Then c!j$-Ovm
Me.txtStatus.Text = "检查修改所有的上标格式" n)[{nkS6[
V:yia^1
CheckSuperScript Sl{]Z,
N U\B
End If f BukrPsV
`vUilh ^c
If Me.chkStyle.Value Then Z}WMpp^r
Me.txtStatus.Text = "设置样式,请稍候...." Z?dz@d%C
DoEvents >NK*$r8
CeateOrModifyStyle JH5ckgdZ
End If =%p0rz|b
E QMn'>
\y{C>!WX4
<&Y7Q[
ClearDomain s<aJ pi{n4
va| 1N/&
)]?sCNb
ss.wX~I
If Me.chkLIST.Value Then r
5:DIA!
Me.txtStatus.Text = "将所有自动列表标题转化为人工标题形式" 6 fL=2a
IL&Mf9m
ConvertListToOrdinary \&"gCv#
End If *i&ks>4N
[>v.#:YM^
>q"mI6F
Dim pType As String, trimpTEXT As String +H8]5~',L%
If Me.chkNum.Value = True Then E]i3E[T
Me.txtStatus.Text = "转换全角数字形式为半角" O*X]oX
ConvertWidth "1", "1" eqg|bc[i!t
DoEvents [Jwo,?w
ConvertWidth "2", "2" pm@Mlwg`1
DoEvents REli`"bR
ConvertWidth "3", "3" P @G2F:
}
DoEvents FG:(H0
ConvertWidth "4", "4" 4Y;z46yM%
DoEvents E&
/#Ov
ConvertWidth "5", "5" 5v
6*.e'p
DoEvents )Z,O*u*
ConvertWidth "6", "6" KHI-m9(
DoEvents &KmVtj
ConvertWidth "7", "7" r_F\]68
DoEvents VPet1hAy
ConvertWidth "8", "8" xZwG@+U=X
DoEvents ;&oS=6$
ConvertWidth "9", "9" >2tYw,m
DoEvents 0p)
#!$
ConvertWidth "0", "0" 3* 1cCM42
DoEvents xhWWl(r`5
ConvertWidth "a", "a" I ze+](
DoEvents [}|x@
v9
ConvertWidth "b", "b" :H@Q`g u
DoEvents &iORB
ConvertWidth "c", "c" nd}[X[ay
DoEvents GU([A@;
ConvertWidth "d", "d" 3)3?/y)_
DoEvents =#
<!s!
ConvertWidth "e", "e" }CIH1
q3P
DoEvents uD}Q}]Z
ConvertWidth "f", "f" TY"8.vd
DoEvents 9rf6,hF
ConvertWidth "g", "g" i^f*Em1
DoEvents 0NL~2Qf_4
ConvertWidth "h", "h" k+t?EZ6L
DoEvents N8#wQ*MM>
ConvertWidth "i", "i" W9+H/T7!
DoEvents ~+
Mp+gE
ConvertWidth "j", "j" 'S;INs2|->
DoEvents 'pa[z5{k+
ConvertWidth "k", "k" \QGh@AQp"
DoEvents eVGO6 2|!
ConvertWidth "l", "l" 3rBSwgRl
DoEvents )[oegfnn-
ConvertWidth "m", "m" 0Q`Dp;a5&
DoEvents &@<Z7))
ConvertWidth "n", "n" '1'De^%6W
ConvertWidth "o", "o" jJml[iC
ConvertWidth "p", "p" ibAZ=RD
ConvertWidth "q", "q" NO+.n)etGb
ConvertWidth "r", "r" *j6KQZ"
ConvertWidth "s", "s" aA7}>
ConvertWidth "t", "t" HRn
Q*
ConvertWidth "u", "u" B<zoa=
ConvertWidth "v", "v" K&3,J7&&
ConvertWidth "w", "w" @y]ek/
ConvertWidth "x", "x" OX-t#R`
ConvertWidth "y", "y" 8iA[w-Pv
ConvertWidth "z", "z" _)XQb1]
ConvertWidth "A", "A" G)t_;iNL|
ConvertWidth "B", "B" IOhJL'r
ConvertWidth "C", "C" r$T\@oTL
ConvertWidth "D", "D" F>RL&i
ConvertWidth "E", "E" V"K-aO&
ConvertWidth "F", "F" 6Cfu19Dx
ConvertWidth "G", "G" n@[_lNa4GD
ConvertWidth "H", "H" I&vD >a5#
ConvertWidth "I", "I" >pdWR1ox
ConvertWidth "J", "J" _3~/Z{z8
ConvertWidth "K", "K" y(^t &tgjS
ConvertWidth "L", "L" C>wOoXjt
ConvertWidth "M", "M" @G,p
M: t
ConvertWidth "N", "N" '{*{
ConvertWidth "O", "O" `ECY:3"$KA
ConvertWidth "P", "P" 3CcCcZ9I
ConvertWidth "Q", "Q" UTwXN |'|
ConvertWidth "R", "R" Gj!9#on$7R
ConvertWidth "S", "S" fqpbsM;M]
ConvertWidth "T", "T" VokIc&!Uz
ConvertWidth "U", "U" ]ie38tX$
ConvertWidth "V", "V" >>bsr#aJ
ConvertWidth "W", "W" Sqn|
ConvertWidth "X", "X" ",O |uL
ConvertWidth "Y", "Y" 'o}v{f
ConvertWidth "Z", "Z" oN({X/P2j
ConvertWidth "^l", "^p" [ICFPY6
ConvertWidth "(", "(" v]{F.N
ConvertWidth ")", ")" QP>tu1B|
VW&EdrR,S
End If {G. W?
6Ft?9
B(F:
With ActiveDocument JPO'1D)
Dim tbl As Table }$%j} F{
For Each tbl In .Tables WVZ](D8Gc]
tbl.Rows.Alignment = wdAlignRowCenter M$YU_RPl+
tbl.Range.Font.NameFarEast = "楷体" ~?#>QN\\c
tbl.Range.Font.NameAscii = "Times New Roman" Ec'Hlsgh&T
tbl.Range.Font.Size = 10.5 H?oBax:
Next n#$sLXVy
Set tbl = Nothing RRRF/Z;))
End With h@AKfE!\~
OEiu,Y|@l
;YN`E
With ActiveDocument /~~A2.=.
zbY2gq@?
For i = 1 To .TablesOfContents.Count b'r</n
cZ
.TablesOfContents(i).Delete 3V uoDmG
Next 2i0 .x
#z6[8B
C f
s2tN
aW=c.Q.
paraTotal = .Paragraphs.Count UlP2VKM1&
paraCounter = 1 )+7|_7
!x
00SYNG!
LastTitle0No = 0 X<8?>#
LastTitle1No = 0 ^#( B4l!
LastTitle2No = 0 WoV"&9y
LastTitle3No = 0 8FT]B/^&m
LastTitle4No = 0 r+:]lO
LastTableNo = 0 A:b(@'h
LastFigureNo = 0 {=I:K|&
YN]xI
Dim Sec As Long I%(YR"
B_Ul&V
Sec = InputBox("正文从第一节开始?", "节设置", 6) e'I/}J
If Sec = 0 Then aC90IJ8^
Exit Sub WwUhwY1o!L
End If ~F"<N q
0Wkk$0h9
k = 0 Ah2*7@U
Do While (paraCounter < paraTotal) And bContinue 6C'W
k = k + 1 A>\5fO
If .Paragraphs(paraCounter).Range.Information(wdActiveEndSectionNumber) >= Sec Then |qs8(
5z0
Exit Do S4 j5-
End If kI?+\k\V`
paraCounter = paraCounter + 1 +P! ibHfP
If k Mod 20 = 0 Then )fy-]Ky
*
Me.lbCounter.Caption = paraCounter IN8G4\r
DoEvents ~ECIL7,
End If \qf0=CPw8
Loop )2sE9G,
\+M6R<Qw
~%chF/H
Do While (paraCounter < paraTotal) And bContinue Xfc+0$U@
%8O1sF
ParaText = Trim(.Paragraphs(paraCounter).Range.Text) PfR|\{(
ShapeHeight = 0 b1TIVK3m
ShapeWidth = 0 0 i'bo*
;NMv>1fI
CheckPara .Paragraphs(paraCounter).Range, ParaType, rText, ttString, ttNo, ShapeCounter, ShapeHeight, ShapeWidth yopC
<k
q\pI&B
Select Case ParaType jFDVd;#CS
Case "【】表格内容" 9\'JtZO
.Paragraphs(paraCounter).Style = "QLNU表格内容" vmzc0J+3p
Case "章" 9| g]M:{
LastTitle0No = LastTitle0No + 1 %<)!]8}P*
'新一章开始,复位其下属标题编号 q@Aw]Kh
LastTitle1No = 0 m>{a<N
LastTitle2No = 0 \E(^<Af
LastTitle3No = 0 VQ"Z3L3-4
LastTitle4No = 0 NiH =T
gU&y5s~
k = Val(ttNo)
?kIyo
If k = 0 Then '非数字编号章节 lfw|Q@
If ttNo <> NoSeries1(LastTitle0No) Then )-\C{>
rText = "第" & NoSeries1(LastTitle0No) & ttString Wu~cy}\
Me.ErrMsg.AddItem "章节编号错误:" & ParaText CM%Rz-c
End If oBO4a^D
Else ;A6%YY
If Val(ttNo) <> LastTitle0No Then 5^ck$af
rText = "第" & LastTitle0No & ttString 'aWqj+Wbh
Me.ErrMsg.AddItem "章节编号错误:" & ParaText @
D,]v:
End If m]+~F_/
LD*XNcE
End If %}IrZrh
N_^PoX935O
'章段落设置 T>hrKn.!D:
'字体大小:三号16磅小三号15磅四号14磅小四号12磅五号10.5磅小五号9磅 G{.[o6>
.Paragraphs(paraCounter).Style = "QLNU章节" q4#$ca[_ak
.Paragraphs(paraCounter).Range.Select {j6$'v)0
Selection.EndKey unit:=wdLine UY6aD~tD0
tc = Replace(rText, vbCr, "") U)[LKO1
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 1 ", PreserveFormatting:=False 5jq
@ nq6
Case "一级标题" f\;w
(_
LastTitle1No = LastTitle1No + 1 -aq3Lqi
'新一级标题开始,复位其下属标题编号 j
n4|gQ
LastTitle2No = 0 nR]*RIp5
LastTitle3No = 0 =,b6yV+$D
LastTitle4No = 0 J`]9n>G
1oc@]0n
If ttNo <> NoSeries1(LastTitle1No) Then 1=Kt.tuf
rText = NoSeries1(LastTitle1No) & "、" & ttString 4Ei8G]O
$_
Me.ErrMsg.AddItem "一级标题编号错误:" & ParaText 7{Lp/z%r
End If "T$LJ1E
1Q_Q-Z
u`CHM:<<?
'一级标题段落设置 格式:一、标题内容 Cag^$nj
.Paragraphs(paraCounter).Range.Text = rText 5e3p9K`5
.Paragraphs(paraCounter).Style = "QLNU一级标题" a<0q%Ax
.Paragraphs(paraCounter).Range.Select 0QP=$X
Selection.EndKey unit:=wdLine z:a7)z
tc = Replace(rText, vbCr, "") " Tk,
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 1 ", PreserveFormatting:=False ?edf$-"z/
Case "二级标题" Kf-XL),3l
LastTitle2No = LastTitle2No + 1
J8-K
'新二级标题开始,复位其下属标题编号 ;`O9YbP#
LastTitle3No = 0 O3V.4tp
LastTitle4No = 0 cQkj{u
Mkh/+f4
If ttNo <> NoSeries1(LastTitle2No) Then /X]gm\x7s
rText = "(" & NoSeries1(LastTitle2No) & ")" & ttString *knN?`(x
ErrMsg.AddItem "二级标题编号错误:" & ParaText ppo.# p0w
End If 7Ll?#eun
kQ]4Bo
'二级标题段落设置 格式:(一)、标题内容 GorEHlvVh
.Paragraphs(paraCounter).Range.Text = rText QQ`tSYgex
.Paragraphs(paraCounter).Style = "QLNU二级标题" bY-koJo
L+mE&
.Paragraphs(paraCounter).Range.Select M"Af_Pbx
Selection.EndKey unit:=wdLine Yy~xNj5OS
tc = Replace(rText, vbCr, "") &OlX CxH
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 2 ", PreserveFormatting:=False 4.
Q[Tu
R;
w$_1
Case "三级标题" 1N_T/I8_F
LastTitle3No = LastTitle3No + 1 \gu8 ~zK
'新三级标题开始,复位其下属标题编号 ^7uXpqQBr
LastTitle4No = 0
7 }I';>QH
w&@zJ [
If Val(ttNo) <> LastTitle3No Then :>}7^1I
rText = LastTitle3No & ". " & ttString 8BrC@L2E0
Me.ErrMsg.AddItem "三级标题编号错误:" & ParaText
E-%$1=;
XuWX@cK
End If 1s~rWnhVv
'三级标题段落设置 格式:1. 标题内容 2Wg:eh
.Paragraphs(paraCounter).Range.Text = rText ]4ck)zlv
.Paragraphs(paraCounter).Style = "QLNU三级标题" &xt[w>/i
.Paragraphs(paraCounter).Range.Select sib/~j
Selection.EndKey unit:=wdLine e"UXG\8D
tc = Replace(rText, vbCr, "") 7'OR;b$
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 3 ", PreserveFormatting:=False rd>>=~vx=/
Case "四级标题" /6rQ.+|).
LastTitle4No = LastTitle4No + 1 qnHjw Mi
]x).C[^
If Val(ttNo) <> LastTitle4No Then w/^_w5
rText = "(" & LastTitle4No & "). " & ttString =),O ;M
ErrMsg.AddItem "四级标题编号错误:" & ParaText nuDu
9@ 4]t6h[
End If QLU <%w:B
'四级标题段落设置 格式:(1). 标题内容 V?Q45t Ae
.Paragraphs(paraCounter).Range.Text = rText kh@O_Q`
j
.Paragraphs(paraCounter).Style = "QLNU四级标题" Nd]RbX
.Paragraphs(paraCounter).Range.Select -Bq]E,Xf)
Selection.EndKey unit:=wdLine ALn_ifNh
tc = Replace(rText, vbCr, "") y #C9@C
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 4 ", PreserveFormatting:=False 3dz{"hV
]c v/dY#
Case "表格标题" zB`J+r;LU
LastTableNo = LastTableNo + 1 fWC(L s
:f:&B8
If ttNo <> CStr(LastTableNo) Then OLtXk
rText = "表" & LastTableNo & ". " & ttString HE{UgU:tY
ErrMsg.AddItem "表格编号错误:" & ParaText M3elog:M
rizjH+
End If Rp;"]Q&b
yZ!~m3Q
'表格名称段落设置 格式:表1. 表格名称 7O8 @T-f+2
.Paragraphs(paraCounter).Style = "QLNU表格标题" _k :BY
xe = Replace(rText, vbCr, "") aS[y\9(**
.Paragraphs(paraCounter).Range.Select $vK,Gugcx
Selection.MoveEnd wdCharacter, -1 '选择范围包括行尾的换行符。 w_V A:]j4
Selection.Range.Text = xe xbxzB<yL
Selection.EndKey .Tm.M7
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="XE " & """" & xe & """", PreserveFormatting:=False Y4w]jIv
:IU<A G6
Case "表格首行" }Ml BmD
.Paragraphs(paraCounter).Style = "QLNU表格首行" P*i'uN
Case "图片标题" H
"Io!{aKU
LastFigureNo = LastFigureNo + 1 w2!:>8o:
& kVa*O
If ttNo <> CStr(LastFigureNo) Then j\wZjc-j
rText = "图" & LastFigureNo & ". " & ttString kOdA8XRY
ErrMsg.AddItem "表格编号错误:" & ParaText G)^/#d#&
IhBQ1,&J
End If -[J4nN &N
'图片名称段落设置 格式:图1. 图名称 j D*<M/4
.Paragraphs(paraCounter).Range.Text = rText bHcBjk.\
.Paragraphs(paraCounter).Style = "QLNU图片标题" :ssj7wl :
.Paragraphs(paraCounter).Range.Select auB
931|
Selection.EndKey unit:=wdLine $0x+b!_l@
xe = Replace(rText, vbCr, "") }t"K(oamm
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="XE " & """" & xe & """", PreserveFormatting:=False w#hg_RK(Jr
Case "正文" O8A(OfX
'正文名称段落设置 J5{
.Paragraphs(paraCounter).Style = "QLNU正文" KgbBa2@+
Case "文献条目" V;g)
P
With .Paragraphs(paraCounter) QgKR=GR6
'.Range.Select ).`v&-cK4E
'Selection.ClearFormatting $9j>oUG
'.Range.Find.Execute findtext:=rText, replacewith:=strSeperator 'Replacetext 传回了编号及分隔符部分, 而StrSeperator传回了正确的格式与分隔符如“[15] ” *DvX||`&
.Style = "QLNU参考文献" 1JUj e
End With S,C c0)j>
Case "图表注解" oOc-1C
y
With .Paragraphs(paraCounter) 4%zy$,|e
.Range.Font.NameFarEast = "楷体" @ ;@~=w
.Range.Font.NameAscii = "Times New Roman" $&qLrKJ
.Range.Font.Size = 9 '小5号字 +)bn}L>Rl
$a8,C\me?
.Alignment = wdAlignParagraphCenter r\#nBoo(
.LeftIndent = 0 GLESngAl
.RightIndent = 0 k q]E@tE*3
.FirstLineIndent = 0 gG@4MXq.
.LineSpacing = 12 `mW~ {)x
.LineSpacingRule = wdLineSpaceExactly [3sZ=)G
.LineUnitAfter = 0 5~Ek_B
.LineUnitBefore = 0 3=o4ncg(
.OutlineLevel = wdOutlineLevelBodyText 00'SceL=`
.PageBreakBefore = False /_HTW\7,
.RightIndent = 0 pouXt-%2X
.WordWrap = True 6;\1bP?
.LineUnitAfter = 0.5 qdy(C^(fa
/
P
-#y@I
End With $m~&| s
Case Else #_x5-?3
'不作处理 T{^ P
End Select ~QlF(@ue
"wcw`TsK
'含有inlineshape的段落处理 r7].48D
If ShapeHeight > 30 Then ',!jYh}Uxk
.Paragraphs(paraCounter).LineSpacingRule = wdLineSpaceSingle '对有图片的段落设置为单倍行距 rW|%eT*/'A
End If pH.&C 5kA
,;5
%&T
If (ShapeWidth + ShapeHeight) > 150 Then ?{}P#sn
.Paragraphs(paraCounter).Style = "QLNU图片段落" PH&Qw2(Sx
End If PNd'21
N
2z"<m2a
'段落计数器递 5073Q~
paraCounter = paraCounter + 1 hr&&b3W3p
Me.lbCounter.Caption = "当前检测段落:" & paraCounter *!TQC6b$
Me.txtStatus.Text = ParaText b{,v?7^4
DoEvents livKiX`
Loop A`JE(cIz3
End With wdf;LM
>&:}L%
msg = "" )ii aT~
]
,C"6@/:l
For i = 0 To Me.ErrMsg.ListCount - 1 D
vvi)/<
msg = msg & vbCrLf & vbCrLf & Me.ErrMsg.List(i) ,?Ie!r$6
Next ?<BI)[B
q]C_idK=
bcvm]aPu
LLT6*up$
Me.txtStatus.Text = "格式化完成!" & vbCrLf & "开始时间:" & tm1 & vbCrLf & "结束时间:" & Now & vbCrLf & msg po'b((q
Me.cmdCheck.Enabled = True ^|zag
Me.txtStatus.Visible = True ,Y6]x^W
Me.lbParaType.Visible = False '_V9
FWDZ
IY8<
^Q']
bContinue = False ]P#W\LZp
End Sub KQb&7k.
SPRTJdaC9
Sub CheckPara(ByRef ChKRange As Range, ParaType As String, ReplaceTEXT As String, TitleString As String, TitleNo As String, shpCounter As Long, MaxShpHeight As Long, TotalShpWidth As Long) Y3~z#<
Dim pTEXT As String >q&5Z
p-_9I7?
pTEXT = ChKRange.Text }y+Qj6dP
U^|T{g+O
ParaType = "其它" Tn/Z s|
TitleString = pTEXT j1qU 4#Y
TitleNo = "N/A" ]T|$nwQ
BfCM\ij
shpCounter = ChKRange.InlineShapes.Count h~]e~u V
If shpCounter <> 0 Then lwgwdB
MaxShpHeight = 0: TotalShpWidth = 0 N8df1>mW
For i = 1 To shpCounter $Zo|ta^
k = ChKRange.InlineShapes(i).Height ]\ !ka/%
l = ChKRange.InlineShapes(i).Width ykJ+LS{+
If k > MaxShpHeight Then pnE]B0e
MaxShpHeight = k YmFg#eS
End If +TA~RCd
TotalShpWidth = TotalShpWidth + l )eT>[['fm
Next @[?ZwzY:9
If MaxShpHeight > 60 Or TotalShpWidth > 150 Then N%>h>HJ
Exit Sub vf@j d}?
End If 0HU0p!yt&
End If !W8=\:D[
/>}zB![(K
'空行 kr~n5WiAZ
If Len(pTEXT) <= 2 Then ||*F.p
Exit Sub ;,6C&|n]w
End If R4VX*qkB
V sx
I
*k_<|{>j(
'是否为表格中的文字 5,oLl {S'
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdWithInTable) Then 4i{Xs5z
k
ParaType = "表格内容" _q1\8y
k = ActiveDocument.Paragraphs(paraCounter).Range.Information(wdEndOfRangeRowNumber) 7FPSBvU#/
If k = 1 Then Zk lpnL*!
ParaType = "表格首行" )`{m |\b
End If *P9" 1K+
Exit Sub i!8"T#
End If $0K@=7ms
Vt3*~Beb
'例外情况:脚注 T[xIn+w
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdInFootnote) Then <uS/8MP{
ParaType = "脚注" {]8|\CcY?
Exit Sub 52
j3[in
End If P(Rl/eyRM
7g]mrI@
'例外情况:尾注 LQr!0p.i"
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdInEndnote) Then eR>8V8@
ParaType = "尾注" "_LqIW1
Exit Sub jSHFY]2
End If L7aVj&xM
0&fO)de96
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdInHeaderFooter) Then ZiQ<SSo:
ParaType = "页眉页脚" o6;
Exit Sub 9 Xl#$d5
End If Yq51+\d
QICxSk
+>1?ck
With regEX j;E$7QH[
.Global = True c1i:m'b_5
T%&vq6
.Pattern = "^第([1-9]|1|2|3|4|5|6|7|8|一|二|三|四|五|六|七|八|九|十)章(、|\.|\s|。|.)+(.{1,30})$" 1goRO
If regEX.Test(pTEXT) Then Yb`b/BMR
ReplaceTEXT = regEX.Replace(pTEXT, "第$1章 $3") 8<T~AU8'*
TitleString = regEX.Replace(pTEXT, "$3") z9OpMA
TitleNo = regEX.Replace(pTEXT, "$1") *yw!Y{e!9
ParaType = "章" jQ'g'c!
Exit Sub !ry+{v+A
End If EVZ1Z
I<sUB4T>#W
.Pattern = "^(十一|十二|十三|十四|十五|十六|一|二|三|四|五|六|七|八|九|十)(、|\.|\s|。|.)+(.{1,40})$"
s@"|o3BX
If regEX.Test(pTEXT) Then ]S]W|m7=.Z
ParaType = "一级标题" fap]`P~#L
regEX.Execute (pTEXT) svDnw cl
ReplaceTEXT = regEX.Replace(pTEXT, "$1、$3") ](Wa:U}Xs
TitleString = regEX.Replace(pTEXT, "$3") F)X`CG ;t
TitleNo = regEX.Replace(pTEXT, "$1") YaSBIq{z
Exit Sub |n tWMm:(
End If S'qT+pP
#_S]\=N(
'全角或半角括号中的数字 =y@0il+V
.Pattern = "(^\(|()(十一|十二|十三|十四|十五|十六|一|二|三|四|五|六|七|八|九|十)(\)|))(、|\.|\s|。|.)*(.{1,40})$" / [49iIzC
If regEX.Test(pTEXT) Then QtG6v<A
ParaType = "二级标题" x:~XZX\mwH
regEX.Execute (pTEXT) w9<'0wcs
ReplaceTEXT = regEX.Replace(pTEXT, "($2)$5") `?R{sNr.
TitleString = regEX.Replace(pTEXT, "$5") n{MTh_C4n
TitleNo = regEX.Replace(pTEXT, "$2") 0M&n3s{5I
Exit Sub d7G@Z|R3p
End If #oa>Z.?_V
onRTX|#
'阿拉伯数字 1. 2. SPdEO3
.Pattern = "^([1-9]|1|2|3|4|5|6|7|8|9|0){1,2}(、|\.|\s|。|.)+(.{1,80})$" r ~UDK]?V
If regEX.Test(pTEXT) Then wG7>2*(
ParaType = "三级标题" ogQfzk
regEX.Execute (pTEXT) w.aEc}@(^
ReplaceTEXT = regEX.Replace(pTEXT, "$1. $3") '未进行全半角转换,如需要可分成两步分别检测 .TdFI"Yn
TitleString = regEX.Replace(pTEXT, "$3") u0arJU_.)
TitleNo = regEX.Replace(pTEXT, "$1") e21J9e6z
Exit Sub 7]1a3Jk
End If /bo=,%wJ[
^o _J0
]m
'全角或半角括号中的阿拉伯数字 F1_,V
?
.Pattern = "^(^\(|()([0-9]|0|1|2|3|4|5|6|7|8|9){1,2}(\)|))(、|\.|\s|。|.)*(.{1,80})$" (M1YOK) I
If regEX.Test(pTEXT) Then ;Wy03}K4J
ParaType = "四级标题" gl`J(
regEX.Execute (pTEXT) "5k6FV
ReplaceTEXT = regEX.Replace(pTEXT, "($2) $5") KWjhkRK4]
TitleString = regEX.Replace(pTEXT, "$5") kiN,N]-V
TitleNo = regEX.Replace(pTEXT, "$2") \W TKw x
Exit Sub 7?uDh'utt
End If ^yc8is'`
k)Lhzr[
'表格名称 PDw+Q
.Pattern = "^表(\d{1,2}-{0,1}\d{0,1})([、|\.|。|.|\s]{1,9})(.{1,120})$" =hb)e}l
If regEX.Test(pTEXT) Then Or?c21un
ParaType = "表格标题" p&Q
m[!
regEX.Execute (pTEXT) =`|Bof
R
ReplaceTEXT = Trim(regEX.Replace(pTEXT, "表$1. $3")) |hi,]D^Kc
TitleString = Trim(regEX.Replace(pTEXT, "$3")) ZAy/u@qt
TitleNo = Trim(regEX.Replace(pTEXT, "$1")) J|^XD<Y
strSeperator = Trim(regEX.Replace(pTEXT, "$2")) '不知道为什么,但是发现传回的replacetext在修改Paragraph对象的Range.Text后,表格标题就会落入第一个单元格中,所以,只能用Paragraph.Range.Find.Execute方法替换 G8__6v~
Exit Sub CC"a2Hu/
End If E:/!]sm!
DMsqTB`
'图片名称 L>1y[
Q
.Pattern = "^图(\d{1,2}-{0,1}\d{0,1})(、|\.|\s|。|.)+(.{1,120})$" }T\.;$f
If regEX.Test(pTEXT) Then z8"1*V
ParaType = "图片标题" gt.F[q3
regEX.Execute (pTEXT) ^?(#%~NS
ReplaceTEXT = regEX.Replace(pTEXT, "图$1. $3") ?t6wozib2
TitleString = regEX.Replace(pTEXT, "$3") O.QR1
TitleNo = regEX.Replace(pTEXT, "$1") Y7g%nz[[
Exit Sub e~(e&4pb
End If L
-}Uj^yF
;qUB[Kw
'参考文献 [o(!/38"@=
.Pattern = "^([\[|[])(\d+)([]|\]])([、|\.|\s|。|.]{0,1})" '[数字]、 j0~c2
If regEX.Test(pTEXT) Then RV{%@1Pu
ParaType = "文献条目" 9#hp]0S6
'ReplaceTEXT = regEX.Replace(pTEXT, "$1$2$3$4") FGP^rTP)e
'TitleNo = regEX.Replace(pTEXT, "[$2] ") O/Hj-u6&A
Exit Sub 65O 8?I
End If PPySOkmS3
z\UXnRL
prfx = Left(pTEXT, 2) 1Dhe!
n#
If prfx = "注:" Or prfx = "注:" Then _6c/,a8;*J
ParaType = "图表注解" xFThs,w
Exit Sub 'a JE+
End If *tRsm"}
tK
e-Dk9
\MmOI<Hd-
ParaType = "正文" UcB&