Dim bContinue As Boolean HFYe@ 2r
TL-ALtG
Dim regEX As New RegExp d;3f80Kd*
Dim paraCounter As Long '全局段落计数,仅在主程序中可读写,其它过程函数应为只读 n(n7"+B
Q/HEWk
Dim LastTitle0String As String, LastTitle0No As Long n"~K",~P
Dim LastTitle1String As String, LastTitle1No As Long *uxKI:rB:
Dim LastTitle2String As String, LastTitle2No As Long {)kL7>u]^V
Dim LastTitle3String As String, LastTitle3No As Long \f]w'qiW5
Dim LastTitle4String As String, LastTitle4No As Long az
}zoFl
Dim LastTitle5String As String, LastTitle5No As Long !WB3%E,I
Dim LastTabelString As String, LastTableNo As Long C(KV5c
Dim LastFigureString As String, LastFigureNo As Long rc`I l{~k
*Hv d
Dim strSeperator As String <8h3)$
a_D K"8I
Sub ConvertWidth(fTEXT As String, rText As String) zQGj,EAM}
Selection.Find.ClearFormatting Xz/aytp~A
Selection.Find.Replacement.ClearFormatting ;s4e8![o3
Selection.Find.Wrap = wdFindContinue W3X;c*j
Me.txtStatus.Text = "转换全角数字字母" & fTEXT & "形式为半角" & rText t`Xx\
DoEvents 4VA]S
Selection.Find.Execute findtext:=fTEXT, replacewith:=rText, Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue, MatchCase:=True UpiZd/K
End Sub ^g <Lu/5w
v9gaRqi8
Sub ClearDomain() O!F"w!5@
With Selection.Find @te}Asv
.ClearFormatting ^Y8G}Z|
.Replacement.ClearFormatting wSALK)T1{
.Wrap = wdFindContinue B>"-8#B[4
Me.txtStatus.Text = "清除所有域代码" k<o<!
DoEvents ,[_)BM
.Execute findtext:="^d", replacewith:="", Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue, MatchWildcards:=False Jcp=<z*0
End With mkgL/h*
End Sub ZxDh!_[s
S4E@wLi
Private Sub cmdCheck_Click() xi.QHKBZaH
bContinue = True pUgas?e&
Dim NoSeries1(1 To 16) As String Idj
Z2)$
Dim NoSeries2(1 To 16) As String ~jWp
D7px
Dim NoSeries5(1 To 16) As String 27F:-C~.9
Dim NoSeriesRM(1 To 16) As String mndEB!b
Dim paraTotal As Long, ParaText As String }$@K
Dim ttString As String, ttNo As String JvJ)}d$,&
JmBMc}54
Dim ShapeCounter As Long, ShapeHeight As Long, ShapeWidth As Long @ L/i
# M
Y4Mr
Me.txtStatus.Visible = True rd X;
Me.lbParaType.Visible = True 3m~3l d
Me.cmdCheck.Enabled = False <rU+{&FKNL
5["n] i
cvpZF5mL]U
20
Rm|CNH?
pC&i!la{o}
Dim ParaType As String, rText As String n@oSLo`k,`
7i=ER*F~
Selection.WholeStory ,M\/[_:
Selection.NoProofing = True u b@'(*
B\dhw@hM
tm1 = Now Lk)TK/JM)
E
/ycPqD
ActiveWindow.View.Type = wdNormalView 0U2dNLc
TP`"x}ACa?
NoSeries1(1) = "一" X`]>J5
NoSeries1(2) = "二" ])zpx-
NoSeries1(3) = "三" S;{[];
NoSeries1(4) = "四" wA87|YK8*
NoSeries1(5) = "五" k$,y1hH;f8
NoSeries1(6) = "六" 3 "|A5>Vo
NoSeries1(7) = "七" M
l_!)b
NoSeries1(8) = "八" V* ,u;*
NoSeries1(9) = "九" S!
.N3ezn
NoSeries1(10) = "十" ?J"Y4,{
NoSeries1(11) = "十一" YIl,8!
z~
NoSeries1(12) = "十二" ^<aj~0v
NoSeries1(13) = "十三" fKs3H?|
NoSeries1(14) = "十四" OJ7y
NoSeries1(15) = "十五" G<~P||Lu^
NoSeries1(16) = "十六" 2\Yv;J+;
Gl T/JZ9
NoSeries2(1) = "㈠" #vR5a}BAk
NoSeries2(2) = "㈡" U71A#OD^U
NoSeries2(3) = "㈢" <1U *{y
NoSeries2(4) = "㈣" A.!3{pAb
NoSeries2(5) = "㈤" Vl
:M6d1
NoSeries2(6) = "㈥" /\pUA!G)BD
NoSeries2(7) = "㈦" c,*a|@
NoSeries2(8) = "㈧" oTpoh]|[
NoSeries2(9) = "㈨" 7#g<fh
NoSeries2(10) = "㈩" s%N6^}N
r6+IJxUd
NoSeries5(1) = "①" f
a/p
NoSeries5(1) = "②" !:D,|k\m
NoSeries5(3) = "③" HDhG1B"NL
NoSeries5(4) = "④" Mi[,-8Sk
NoSeries5(5) = "⑤" %1i *Y*wg
NoSeries5(6) = "⑥" +C4NhA2
NoSeries5(7) = "⑦" T
zHR
NoSeries5(8) = "⑧" I=8MLv
NoSeries5(9) = "⑨" Lo9
\[4FP
NoSeries5(10) = "⑩" 8KzH
-
tqU8>d0^
z9zo5Xc=
NoSeriesRM(1) = "I" =?hbi]
NoSeriesRM(2) = "II" 1| xKb(_l
NoSeriesRM(3) = "III" tkdyR1-
NoSeriesRM(4) = "IV" G?+]BIiL
NoSeriesRM(5) = "V" A+hT2Ew@t}
NoSeriesRM(6) = "VI" c+<gc:#jy
NoSeriesRM(7) = "VII" (`f)Tt=`
NoSeriesRM(8) = "VIII" fp"GdkO#}i
NoSeriesRM(9) = "IX" \@7 4I7
NoSeriesRM(10) = "X" {6wy}<ynC+
NoSeriesRM(11) = "XI" DEenvS`,P
NoSeriesRM(12) = "XII" ?zK>[L
NoSeriesRM(13) = "XIII" aS+i`A :a
NoSeriesRM(14) = "XIV" Nw3IDy~T
NoSeriesRM(15) = "XV" B=i%Z_r]w
NoSeriesRM(16) = "XVI" zOL*XZ0c
NB&zBJ#
i = MsgBox("为了你的数据安全,请使用单独保存的文件副本进行本操作。" & vbCrLf & "确定继续进行吗?", vbYesNo) T%2%*oa
TyaK_XW
If i = vbNo Then 2\[
Q{T=Qe
Exit Sub #XAH
`
L\
End If 5=.mg6:
.zdmUS:
If Me.chkSuper.Value Then S`[r]msw
Me.txtStatus.Text = "检查修改所有的上标格式" m
gBxcmv
Wp=&nh
CheckSuperScript z|N*Gs>,
wq#'o9s,
End If .@Jos^rxgJ
;BEX|wxn
If Me.chkStyle.Value Then 3>^S6h}o
Me.txtStatus.Text = "设置样式,请稍候...." < 'r<MA<
DoEvents 0h"uJco,
CeateOrModifyStyle jTok1k
End If j1dz'G}hj
i#Fe`Z ~J
;;zd/n2b
RSF@ Oo{
ClearDomain 95-%>?4
#Xun>0
xT8!X5;
`Jl_'P}
If Me.chkLIST.Value Then xb^M33-y
Me.txtStatus.Text = "将所有自动列表标题转化为人工标题形式" EJTa~
mp0!S
ConvertListToOrdinary fH_Xm :%
End If OKNGV,{`
7+J<N@.d
X^.~f+d~
Dim pType As String, trimpTEXT As String ~#JX
0J=
If Me.chkNum.Value = True Then MAG/7T5
Me.txtStatus.Text = "转换全角数字形式为半角" J2$=H1-
ConvertWidth "1", "1" &. "ltB
DoEvents 3;EBKGg|
ConvertWidth "2", "2" 7FP
@ v ng
DoEvents 3WY:Fn+#
ConvertWidth "3", "3" n,|YJ,v[
DoEvents ; 5!8LmZ0#
ConvertWidth "4", "4" FHZQyO<|
DoEvents Hd~fSXFl
ConvertWidth "5", "5" $/P\@|MqYQ
DoEvents vg[zRWh8
ConvertWidth "6", "6" d|$-l:(
J
DoEvents 9CHn6 v ~)
ConvertWidth "7", "7" j(Tk6S
DoEvents _dn*H-5hO
ConvertWidth "8", "8"
W o$UV
DoEvents +D#.u^
ConvertWidth "9", "9" q%Lw#f
DoEvents i &,1
ConvertWidth "0", "0" ;0E[ ;
L!
DoEvents DOWZhD
ConvertWidth "a", "a" 6E:5w9_=c
DoEvents wW'.bqA
ConvertWidth "b", "b" VD2o#.7*eu
DoEvents izr
3{y5
ConvertWidth "c", "c" [N*`3UZk"
DoEvents sQa
9M
ConvertWidth "d", "d" 2H`;?#Uq:
DoEvents ltmD=-]G_
ConvertWidth "e", "e" Th 5}?j7
DoEvents :j%
B(@b
ConvertWidth "f", "f" ]+AgXUrbOD
DoEvents D?9EO=
ConvertWidth "g", "g" yI$MqR
DoEvents ; HjT
ConvertWidth "h", "h" 8BM[c;-{g`
DoEvents X0%BE!
ConvertWidth "i", "i" 6NzS <
DoEvents <+;
cgF!+
ConvertWidth "j", "j" &d[%
DoEvents U{-[lpd
ConvertWidth "k", "k" -<q@0IYyi
DoEvents ltXGm)+
ConvertWidth "l", "l" @-}!o&G0
DoEvents T`| >oX
ConvertWidth "m", "m" HlX 2:\\
DoEvents q3Y49d
ConvertWidth "n", "n" _K|?;j#x0k
ConvertWidth "o", "o" VDPq3`$+v{
ConvertWidth "p", "p" !o/;"'&E
ConvertWidth "q", "q" 5~SBZYI
ConvertWidth "r", "r" (:J
U
ConvertWidth "s", "s" l)91v"vJ
ConvertWidth "t", "t" Kr;F4G|Qt
ConvertWidth "u", "u" 4 !M6RL8{
ConvertWidth "v", "v" ]hA]o7k
ConvertWidth "w", "w" )mRKIM}*W
ConvertWidth "x", "x" u
BBW2
ConvertWidth "y", "y" Kl+4A}Uo
ConvertWidth "z", "z" W:=CpbwENX
ConvertWidth "A", "A" ;Q%3WD
ConvertWidth "B", "B" b]5S9^=LI
ConvertWidth "C", "C" ;F>I+l_X
ConvertWidth "D", "D" R2nDK7j
ConvertWidth "E", "E" 4S,/Z{ J.
ConvertWidth "F", "F" 0:k
MnHn\
ConvertWidth "G", "G" ,koG*sn
ConvertWidth "H", "H" <e' l"3+9(
ConvertWidth "I", "I" ))#_@CwRr
ConvertWidth "J", "J" F[U0TP@&*
ConvertWidth "K", "K" %Wb$qpa
ConvertWidth "L", "L" M%FKg/
ConvertWidth "M", "M" fuA8jx
ConvertWidth "N", "N" )]m_ L$9
ConvertWidth "O", "O" t)*A#
ConvertWidth "P", "P" m_>~e}2'A
ConvertWidth "Q", "Q" ("j*!Dsd
ConvertWidth "R", "R" ^]?Yd )v
ConvertWidth "S", "S" O6r.q&U
ConvertWidth "T", "T"
05vu{>
ConvertWidth "U", "U"
J~rjI24
ConvertWidth "V", "V" 8]0?mV8iOE
ConvertWidth "W", "W" 4 {3<
`
ConvertWidth "X", "X" |0aGX]Y
ConvertWidth "Y", "Y" |:d:uj/
ConvertWidth "Z", "Z" N!=Q]\ZD
ConvertWidth "^l", "^p" `v$Bib)
ConvertWidth "(", "(" jh.e&6
ConvertWidth ")", ")" dZjh@yGP.
h5m6 )0"
End If sh8(+hg
d0@czNWIC
With ActiveDocument qt#4i.Iu+
Dim tbl As Table u=p-]?
For Each tbl In .Tables ?VT
]bxb
tbl.Rows.Alignment = wdAlignRowCenter O7tL,)Vv
tbl.Range.Font.NameFarEast = "楷体" e!*%U=[Q
tbl.Range.Font.NameAscii = "Times New Roman" JB\BP$ap
tbl.Range.Font.Size = 10.5 >R8eAR$N
Next 3`\)Qm
Set tbl = Nothing ffE>%M*
End With .(8eWc YK
s2\6\8Ipn
vD4<G{
With ActiveDocument +\`t@Ht#
v_ W03\
For i = 1 To .TablesOfContents.Count 9w,u4q
.TablesOfContents(i).Delete t%>x}b"2T
Next rlVo}kc7:
;Ajy54}7
[=I==?2`X
Ol.
rjz9
paraTotal = .Paragraphs.Count mnWbV\ VY
paraCounter = 1 ]%/a
'[
<\S
j5
LastTitle0No = 0 @V#
wYt
LastTitle1No = 0 nXF|AeAco
LastTitle2No = 0 $ *^E
LastTitle3No = 0 {uMqd-Uu
LastTitle4No = 0
H!ISQ8{V
LastTableNo = 0 {
V9}W<
LastFigureNo = 0 2T#>66^@q
X~Vr}
Dim Sec As Long }X*.Vv A
wa4(tM2
Sec = InputBox("正文从第一节开始?", "节设置", 6) 'P?DZE
If Sec = 0 Then H(Q|qckj
Exit Sub $5m_)]w4a
End If 7Ke#sW.HN
zE<G wVI~
k = 0 LC:bHM,e
Do While (paraCounter < paraTotal) And bContinue V{G9E
k = k + 1 /Q[M2DN@
If .Paragraphs(paraCounter).Range.Information(wdActiveEndSectionNumber) >= Sec Then W&(98}oT
Exit Do wC[Bh^]
End If K=C).5=U
paraCounter = paraCounter + 1 O1K~]Nt
If k Mod 20 = 0 Then Lg4I6 G
Me.lbCounter.Caption = paraCounter j{a3AEmps
DoEvents {^n\
r^5
End If *]_GFixi
Loop *A
d7GG1/u
cxQ8/0^
`mTc
Do While (paraCounter < paraTotal) And bContinue 2M
d'<.
6
bnuC
ParaText = Trim(.Paragraphs(paraCounter).Range.Text) w~(x*R}
ShapeHeight = 0 ZIrJ"*QO=
ShapeWidth = 0 Nd4!:.
)CC rO
CheckPara .Paragraphs(paraCounter).Range, ParaType, rText, ttString, ttNo, ShapeCounter, ShapeHeight, ShapeWidth PNM
f5'@m
|K6hY-uC
Select Case ParaType xd`!z`X!,s
Case "【】表格内容" a0ze7F<(
.Paragraphs(paraCounter).Style = "QLNU表格内容" ~.w Db,*
Case "章" R]{AJ"p
LastTitle0No = LastTitle0No + 1 4?^t=7N
'新一章开始,复位其下属标题编号 uua1_#a
LastTitle1No = 0 tcxs%yWO1
LastTitle2No = 0 c;e2=
A
LastTitle3No = 0 lhA<wV1-9G
LastTitle4No = 0 Li;(~_62a]
J]|
lCwF
k = Val(ttNo) |+MV%QG;
If k = 0 Then '非数字编号章节 p;rGaLo:u
If ttNo <> NoSeries1(LastTitle0No) Then :+>:>$ao
rText = "第" & NoSeries1(LastTitle0No) & ttString ZXj;ymC'
Me.ErrMsg.AddItem "章节编号错误:" & ParaText `FM^)(wT
End If %L9A6%gr
Else VX;tglu2
If Val(ttNo) <> LastTitle0No Then mjqVP.
rText = "第" & LastTitle0No & ttString D;0xROW8{
Me.ErrMsg.AddItem "章节编号错误:" & ParaText 1y5$
End If _}B:SM
;hLne0|)}
End If /M "E5
kDG'5X;+
'章段落设置 j\SW~}d9
'字体大小:三号16磅小三号15磅四号14磅小四号12磅五号10.5磅小五号9磅 )
{oVVLs
.Paragraphs(paraCounter).Style = "QLNU章节" :i6k6=
.Paragraphs(paraCounter).Range.Select :J}@*>c
Selection.EndKey unit:=wdLine _(8HK
tc = Replace(rText, vbCr, "")
88ydAx#P
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 1 ", PreserveFormatting:=False O$=)
Case "一级标题" }3Y3f).ZW
LastTitle1No = LastTitle1No + 1 Il
c FW
'新一级标题开始,复位其下属标题编号 8\^[@9g3\3
LastTitle2No = 0 ep<2u
x
LastTitle3No = 0
}[<eg>9#
LastTitle4No = 0 afMIq Q?
Ng} AEAFp
If ttNo <> NoSeries1(LastTitle1No) Then <IBzh_
rText = NoSeries1(LastTitle1No) & "、" & ttString d>Z{TFY
Me.ErrMsg.AddItem "一级标题编号错误:" & ParaText '.wyfS H@
End If 1=t\|Th-
~=,|dGAa$
RZ[r XV5
'一级标题段落设置 格式:一、标题内容 L.xzI-I@D
.Paragraphs(paraCounter).Range.Text = rText #?z1cgCg
.Paragraphs(paraCounter).Style = "QLNU一级标题" nJ4CXSdE
.Paragraphs(paraCounter).Range.Select &n:F])`2
Selection.EndKey unit:=wdLine N|ut^X+|\
tc = Replace(rText, vbCr, "") ;U|^Tsuc`
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 1 ", PreserveFormatting:=False i%~4 >k
Case "二级标题" Xx0}KJq~"
LastTitle2No = LastTitle2No + 1 +0O{"XM
'新二级标题开始,复位其下属标题编号 O$%C(n(
LastTitle3No = 0 4JHFn [%
LastTitle4No = 0 }hFjl4`xa
\8!&XcA
If ttNo <> NoSeries1(LastTitle2No) Then <Zc:
rText = "(" & NoSeries1(LastTitle2No) & ")" & ttString 2Ax HhD.
ErrMsg.AddItem "二级标题编号错误:" & ParaText z.[ Ok
End If ?7cF_Zvve
[-sE:O`yt
'二级标题段落设置 格式:(一)、标题内容 B94mh
.Paragraphs(paraCounter).Range.Text = rText M#qZ0JT4
.Paragraphs(paraCounter).Style = "QLNU二级标题" ~qiSkG
1&
k_&o
.Paragraphs(paraCounter).Range.Select ;6} *0V_!k
Selection.EndKey unit:=wdLine S{NfU/:
dL
tc = Replace(rText, vbCr, "")
F%6`D
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 2 ", PreserveFormatting:=False G'z&U?Ng
swVq%]')"
Case "三级标题" |^ml|cb
LastTitle3No = LastTitle3No + 1 N+?kFob
'新三级标题开始,复位其下属标题编号 m GWT</=[$
LastTitle4No = 0 .Wq`qF(;
e.0vh?{\
If Val(ttNo) <> LastTitle3No Then &0
VM <
rText = LastTitle3No & ". " & ttString 9k^;]jE
Me.ErrMsg.AddItem "三级标题编号错误:" & ParaText eD, 7gC-
jBEt!Azur
End If .O'gD.|^N
'三级标题段落设置 格式:1. 标题内容 r^?%N3
.Paragraphs(paraCounter).Range.Text = rText {A(=phN
.Paragraphs(paraCounter).Style = "QLNU三级标题" !o 7uZC\
.Paragraphs(paraCounter).Range.Select VB 8t"5
Selection.EndKey unit:=wdLine F^=|NlU&%
tc = Replace(rText, vbCr, "") eP3)8QC
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 3 ", PreserveFormatting:=False $s hlNW\
Case "四级标题" MQQ!@I`
LastTitle4No = LastTitle4No + 1 5|-(Ic
gTR:9E:B
If Val(ttNo) <> LastTitle4No Then )^^r\
rText = "(" & LastTitle4No & "). " & ttString 4\?I4|{pC
ErrMsg.AddItem "四级标题编号错误:" & ParaText Wv"[,5
Z13
m)q;eQs
End If *4^!e/
'四级标题段落设置 格式:(1). 标题内容 0n_Cuh\
.Paragraphs(paraCounter).Range.Text = rText MWCP/~>a2
.Paragraphs(paraCounter).Style = "QLNU四级标题" %xR;8IO
.Paragraphs(paraCounter).Range.Select nYuZg6K
Selection.EndKey unit:=wdLine 3Nh;^
tc = Replace(rText, vbCr, "") u+zq:2)H6
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 4 ", PreserveFormatting:=False 9`)NFy?
xnu|?;.}!
Case "表格标题" }b
YiyG\
LastTableNo = LastTableNo + 1 N2}].}
A;h0BQm/j
If ttNo <> CStr(LastTableNo) Then 1GW=QbO 6
rText = "表" & LastTableNo & ". " & ttString Uc}L/ax
ErrMsg.AddItem "表格编号错误:" & ParaText
%f@VOS
s
0X)'8N
End If q5[%B K
2D
MH@U2
'表格名称段落设置 格式:表1. 表格名称 SF;;4og
.Paragraphs(paraCounter).Style = "QLNU表格标题" h"YIAQ',
xe = Replace(rText, vbCr, "") (0"9562
.Paragraphs(paraCounter).Range.Select -{ZTp8P>
Selection.MoveEnd wdCharacter, -1 '选择范围包括行尾的换行符。
CD^_>sya
Selection.Range.Text = xe WW;S
Selection.EndKey .l*]W!L]
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="XE " & """" & xe & """", PreserveFormatting:=False R$*{@U
;sa-Bh=j^
Case "表格首行" e@L'H)w,
.Paragraphs(paraCounter).Style = "QLNU表格首行" B{|P}fN5}
Case "图片标题" 5jg^
12EP
LastFigureNo = LastFigureNo + 1 y-"*[5{W
>;QkV6i7
If ttNo <> CStr(LastFigureNo) Then $xS `i-|
rText = "图" & LastFigureNo & ". " & ttString UsYH#?|O
ErrMsg.AddItem "表格编号错误:" & ParaText {61NLF\0H
X63DBF4A
End If -?!Z/#i4
'图片名称段落设置 格式:图1. 图名称 ''wWw(2O
.Paragraphs(paraCounter).Range.Text = rText q01zN:|-1
.Paragraphs(paraCounter).Style = "QLNU图片标题" D;<Qm,[
.Paragraphs(paraCounter).Range.Select ;2}0Hr'|
Selection.EndKey unit:=wdLine HF5aU
:M
xe = Replace(rText, vbCr, "") ~]A';xH&
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="XE " & """" & xe & """", PreserveFormatting:=False gB<p
Case "正文"
mYb8
'正文名称段落设置 B\}E v&
.Paragraphs(paraCounter).Style = "QLNU正文" +
&b`QcH<
Case "文献条目" 8\y%J!b
With .Paragraphs(paraCounter) x-U^U.i@
'.Range.Select -b(:kAwStk
'Selection.ClearFormatting C>@~W(IE
'.Range.Find.Execute findtext:=rText, replacewith:=strSeperator 'Replacetext 传回了编号及分隔符部分, 而StrSeperator传回了正确的格式与分隔符如“[15] ” [(`T*c.#.X
.Style = "QLNU参考文献" KI$?0O
End With /,= wP)
Case "图表注解" q!<`ci,uS
With .Paragraphs(paraCounter) y3$'
gu|
.Range.Font.NameFarEast = "楷体" (>>pla^
.Range.Font.NameAscii = "Times New Roman" S]1+tj
.Range.Font.Size = 9 '小5号字 qEf)TW(
[ WZ<d^L
.Alignment = wdAlignParagraphCenter cCU'~
.LeftIndent = 0 s+^o[R
T3
.RightIndent = 0 *Yvfp{B
.FirstLineIndent = 0 :M ix*NCf
.LineSpacing = 12 mb?DnP,z
.LineSpacingRule = wdLineSpaceExactly 'oEFNC9V
.LineUnitAfter = 0 ZH`6>:
.LineUnitBefore = 0 T |'Ur#
.OutlineLevel = wdOutlineLevelBodyText o&?Tz*"l
.PageBreakBefore = False q?Q"Ab
.RightIndent = 0 ~@bCSOIy
.WordWrap = True ,q/K&'0`
.LineUnitAfter = 0.5 ^C):yxNP
pp#Kb 2*
End With tZU"Ud
Case Else f<WnPoV
'不作处理 *s?&)][
End Select "`,PLC
VPn#O
'含有inlineshape的段落处理 :
Ot\l
If ShapeHeight > 30 Then ^$_ifkkLz
.Paragraphs(paraCounter).LineSpacingRule = wdLineSpaceSingle '对有图片的段落设置为单倍行距 =o _d2Ak
End If oRy?Dx+H
akBR"y:~:H
If (ShapeWidth + ShapeHeight) > 150 Then _ZD)#?
.Paragraphs(paraCounter).Style = "QLNU图片段落" =}r&>|rrJ
End If /43DR;4
[gzw<b:
`
'段落计数器递 8+
B. x
paraCounter = paraCounter + 1 cWp
n/.a
Me.lbCounter.Caption = "当前检测段落:" & paraCounter Gr?"okaA
Me.txtStatus.Text = ParaText UY{
Uo@k9x
DoEvents N!"GwH
Loop ?GD{}f33
End With 1w+&Y;d|
0tn5>Dsk
msg = "" rgIJ]vmy<H
L|6c lGp
For i = 0 To Me.ErrMsg.ListCount - 1 m3 (fr
msg = msg & vbCrLf & vbCrLf & Me.ErrMsg.List(i) 9T|7edl
Next aiw~4ix
R.|fc5_"+
/n?5J`6
J`} /+WN 7
Me.txtStatus.Text = "格式化完成!" & vbCrLf & "开始时间:" & tm1 & vbCrLf & "结束时间:" & Now & vbCrLf & msg
DD|%F
Me.cmdCheck.Enabled = True ?$;_a%v6
Me.txtStatus.Visible = True KzeA+PI
Me.lbParaType.Visible = False Si*Pi
6l [TQ
bContinue = False jfqWcX.X=
End Sub .m/Lon E
'iMI&?8u
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) ;b
cy(Fp,\
Dim pTEXT As String 2{XQDOyA
w*#k&N[X
pTEXT = ChKRange.Text +5?hkQCX1^
G~a/g6M4
ParaType = "其它" u/y`M]
17
TitleString = pTEXT <pYGcVB9V
TitleNo = "N/A" 5&2=;?E
O
w69`vK
shpCounter = ChKRange.InlineShapes.Count 5:CC\!&QBV
If shpCounter <> 0 Then '/;#{("
MaxShpHeight = 0: TotalShpWidth = 0 %r6~5_A
For i = 1 To shpCounter $NG}YOP)@
k = ChKRange.InlineShapes(i).Height ):LJ {.0R
l = ChKRange.InlineShapes(i).Width ID'@}69.S
If k > MaxShpHeight Then BIbcm,YQ
MaxShpHeight = k #B`"B
End If cKF02?)TX
TotalShpWidth = TotalShpWidth + l s4MP!n?gB
Next AUS?Pt[w
If MaxShpHeight > 60 Or TotalShpWidth > 150 Then %~^R Iwm
Exit Sub !j %)nU
End If wxo(
End If SY <!-g<1F
3'u%[bx
E
'空行 s.C-II?e
If Len(pTEXT) <= 2 Then *qY`MW
Exit Sub =#T6,[5
End If _4zlEo-.gU
$hn_4$
^o:0 Y}v=
'是否为表格中的文字 }[D~#Z!k
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdWithInTable) Then <B$Lu4b@c
ParaType = "表格内容" 8xg:ItJaA0
k = ActiveDocument.Paragraphs(paraCounter).Range.Information(wdEndOfRangeRowNumber) /
)5B
If k = 1 Then Mk|h ><Q"
ParaType = "表格首行" +*)B;)P
End If "H%TOk7l
Exit Sub F2oY_mA
End If Q`AJR$L
fn#b3ee
'例外情况:脚注 z~o%U&DO}
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdInFootnote) Then L V33vy
ParaType = "脚注" $L:g7?)k
Exit Sub %Dsa
~{
End If g6QkF41nG
RJF1~9
'例外情况:尾注 RS<c&{?
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdInEndnote) Then faD
(,H
ParaType = "尾注" EW#.)@-
Exit Sub ./5|i*ow
End If a2Q9tt>Q
T"9`[Lzva
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdInHeaderFooter) Then ,!%[CpM3
ParaType = "页眉页脚" 1;vn*w`p
Exit Sub a_QO)
End If a/L?R
Uu
'n!;7*
r^ #.yUz
With regEX 39"8Nq|e
.Global = True a/_
sL(F{
Xd|@w{.m*
.Pattern = "^第([1-9]|1|2|3|4|5|6|7|8|一|二|三|四|五|六|七|八|九|十)章(、|\.|\s|。|.)+(.{1,30})$" j*W]^uT,
If regEX.Test(pTEXT) Then 4w]u: eU
ReplaceTEXT = regEX.Replace(pTEXT, "第$1章 $3") ;13lu1
TitleString = regEX.Replace(pTEXT, "$3") {U^mL6=&v
TitleNo = regEX.Replace(pTEXT, "$1") z>~`9Qiw'
ParaType = "章" 7ou2SL}k
Exit Sub 1#]tCi`
End If RF g$N@g,
?PyI#G
.Pattern = "^(十一|十二|十三|十四|十五|十六|一|二|三|四|五|六|七|八|九|十)(、|\.|\s|。|.)+(.{1,40})$" D\j1`
If regEX.Test(pTEXT) Then `U(A 5
ParaType = "一级标题" [^ 7^&/0
regEX.Execute (pTEXT) G:u[Lk#6K
ReplaceTEXT = regEX.Replace(pTEXT, "$1、$3") Sr2c'T"
TitleString = regEX.Replace(pTEXT, "$3") HewVwD<C
TitleNo = regEX.Replace(pTEXT, "$1") ,D
;`t
Exit Sub C&<f YCwG
End If s(Kf%ZoE
z56W5g2
'全角或半角括号中的数字 Eto0>YyZ
.Pattern = "(^\(|()(十一|十二|十三|十四|十五|十六|一|二|三|四|五|六|七|八|九|十)(\)|))(、|\.|\s|。|.)*(.{1,40})$" KQ3)^
J_Z
If regEX.Test(pTEXT) Then 'OBAnE<.
ParaType = "二级标题" Z9=Cw0( w?
regEX.Execute (pTEXT) 6prN,*k5
ReplaceTEXT = regEX.Replace(pTEXT, "($2)$5") @] )a
TitleString = regEX.Replace(pTEXT, "$5") Xb$)}n\9
TitleNo = regEX.Replace(pTEXT, "$2") rCYNdfdpp
Exit Sub g"#R>&P
End If 6<]&T lS]
YD jQ&EH
'阿拉伯数字 1. 2. .t"s>jq 1
.Pattern = "^([1-9]|1|2|3|4|5|6|7|8|9|0){1,2}(、|\.|\s|。|.)+(.{1,80})$" I+`~6
If regEX.Test(pTEXT) Then us`hR!_
ParaType = "三级标题" vx!nC}f"k`
regEX.Execute (pTEXT) v{?9PRf\s
ReplaceTEXT = regEX.Replace(pTEXT, "$1. $3") '未进行全半角转换,如需要可分成两步分别检测 t4h05 i
TitleString = regEX.Replace(pTEXT, "$3") quGb;)3
TitleNo = regEX.Replace(pTEXT, "$1") I|Z5*iXqCm
Exit Sub l4R:_Z<
End If wg!
@f*/V e0.
'全角或半角括号中的阿拉伯数字 NYR^y\u
.Pattern = "^(^\(|()([0-9]|0|1|2|3|4|5|6|7|8|9){1,2}(\)|))(、|\.|\s|。|.)*(.{1,80})$" rU.ew~
If regEX.Test(pTEXT) Then nV:.-JR
ParaType = "四级标题" uO7Ti]H
regEX.Execute (pTEXT) z<^HohT
ReplaceTEXT = regEX.Replace(pTEXT, "($2) $5") UvQxtT]
TitleString = regEX.Replace(pTEXT, "$5") R8o9$&4_
TitleNo = regEX.Replace(pTEXT, "$2") 86IAAO`#
Exit Sub q G=`'%,m
End If bB)EJCPq>
xiA9X]FB
'表格名称 /=m=i%& #
.Pattern = "^表(\d{1,2}-{0,1}\d{0,1})([、|\.|。|.|\s]{1,9})(.{1,120})$" ;\Wg>sq
If regEX.Test(pTEXT) Then .%WbXs
ParaType = "表格标题" P>4(+s
regEX.Execute (pTEXT) {r'#(\
ReplaceTEXT = Trim(regEX.Replace(pTEXT, "表$1. $3")) iKp4@6an
TitleString = Trim(regEX.Replace(pTEXT, "$3")) =\:YNP/
TitleNo = Trim(regEX.Replace(pTEXT, "$1")) 2{+\\.4Evk
strSeperator = Trim(regEX.Replace(pTEXT, "$2")) '不知道为什么,但是发现传回的replacetext在修改Paragraph对象的Range.Text后,表格标题就会落入第一个单元格中,所以,只能用Paragraph.Range.Find.Execute方法替换 QdC>fy
Exit Sub l<7 b
End If zq{L:.#ha
VCbnS191*
'图片名称 20% xD e
.Pattern = "^图(\d{1,2}-{0,1}\d{0,1})(、|\.|\s|。|.)+(.{1,120})$" J"6_H =s
If regEX.Test(pTEXT) Then G;fP
ParaType = "图片标题" zUwz[^d<C
regEX.Execute (pTEXT) [2)Y0; ["
ReplaceTEXT = regEX.Replace(pTEXT, "图$1. $3") ua4QtDSs
TitleString = regEX.Replace(pTEXT, "$3") )vuxy
TitleNo = regEX.Replace(pTEXT, "$1") O%0G37h
Exit Sub G_42ckLq
End If [|k@Suv |z
>K50 h
'参考文献 @*%5"~F
.Pattern = "^([\[|[])(\d+)([]|\]])([、|\.|\s|。|.]{0,1})" '[数字]、 V)N9V|O'
If regEX.Test(pTEXT) Then g%4|vA8
ParaType = "文献条目" *e
_ /D$SC
'ReplaceTEXT = regEX.Replace(pTEXT, "$1$2$3$4") aeH
9:GQ6
'TitleNo = regEX.Replace(pTEXT, "[$2] ") Rq4\~F?
Exit Sub tQ?? nI2
End If l Fzb$k}_{
#Fu OTBNvB
prfx = Left(pTEXT, 2) Q6.},o
If prfx = "注:" Or prfx = "注:" Then (]mN09uE
ParaType = "图表注解" U6.$F#n
Exit Sub L2Gm0 v
End If wk8XD(
&
og2]B\mN4
3b#KrN'
ParaType = "正文" Bsz kQ>#6
I"T
_<
End With bE]2:~
End Sub H~||]_
q|
5Z`f)qE
Sub ConvertListToOrdinary() u
ERc\TZ
Dim st As Paragraph Ae`K
9
With ActiveDocument G9Xrwk<g4
For i = .Paragraphs.Count To 1 Step -1 lW^RwNcd
Set st = .Paragraphs(i) evimnV
lst = st.Range.ListFormat.ListString d['BtVJ
If lst <> "" Then dLQ!hKD~
st.Range.ListFormat.RemoveNumbers #[I`VA\x
st.Range.InsertBefore lst & " " /7P4[~vw
End If )5&w
Next -I4@` V
End With lD
!^MqK
Set st = Nothing EkOBI[`
End Sub xQaN\):^8
=C<_rBY
Private Sub UserForm_Activate() ?LvZEiJ
Me.lbTotal.Caption = "当前文章段落总数:" & ActiveDocument.Paragraphs.Count & " 共" & ActiveDocument.Sections.Count & "节" uiDR}
Me.lbTotal.Font.Bold = True gfih;i.pY
Me.txtStatus.Visible = False T:na\y/{j
Me.cmdCheck.Enabled = True Dyt}"r\
#MOEY|6
End Sub -f Zm_FE
(MNbABZQ
<5C3c&sds
Sub CheckSuperScript() mjB%"w!S
Selection.Find.ClearFormatting 7*@qd&
Selection.Find.Replacement.ClearFormatting Nz5gu.a6{L
With Selection.Find sEhdkN}6
.Text = "[【\[[〖](*)[】\]〗]]" kCN9`9XI{
.Replacement.Text = "[\1]" 9.1%T06$
.Replacement.Font.Superscript = True 'H*S-d6V
'.Replacement.Font.Color = wdColorBlue =$b^X?x
.Forward = True bS*
"C,b~s
.Wrap = wdFindContinue u^iK?S#Ci8
.FORMAT = True SC86+
.MatchCase = False 5;dnxhf
.MatchWholeWord = False LRB#|PW
.MatchByte = False )ALf!E%{
.MatchAllWordForms = False #W!@j"8eK
.MatchSoundsLike = False `;QpPSw +
.MatchWildcards = True 'y;[
fwo7
End With M@8
<^CK
Selection.Find.Execute Replace:=wdReplaceAll BhdJ/C^
End Sub ir%/9=^d
H$1R\rE`
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) wCn W]<+
bContinue = False Zroj-3-X~
Set regEX = Nothing zy+|)^E
End Sub L6 hTz'
u4#BD!W
Sub CeateOrModifyStyle() f&{2G2O%
' b.C!4^
' W~dS8B=<
Dim stl As Style 10}\7p8
}v@w(*)h:
Options.Pagination = False Et`z7Q*e
aSKI%<?xN
On Error Resume Next (B,CL222x
For Each stl In ActiveDocument.Styles
`sJkOEc`
stl.Delete Jqjb@'i
Next |910xd`Z
On Error GoTo 0 hQ8/-#LO_
^
U:pv0Qz
Set stl = Nothing
C4Bh
#C
tR0o6s@v/<
DoEvents 1(rH5z'F
On Error Resume Next QXgh[9wG
qBKIl=
ne
ActiveDocument.Styles.Add Name:="BaseStyle", Type:=wdStyleTypeParagraph gZ/M0px
7c4\'dt#
ActiveDocument.Styles.Add Name:="QLNU论文题目", Type:=wdStyleTypeParagraph Os?~U/
ActiveDocument.Styles.Add Name:="QLNU中文摘要", Type:=wdStyleTypeParagraph
Sn" 1XU
3Yg/-=U(
ActiveDocument.Styles.Add Name:="QLNU英文标题", Type:=wdStyleTypeParagraph x*bM C&Ea
ActiveDocument.Styles.Add Name:="QLNU英文摘要", Type:=wdStyleTypeParagraph obaJT"1
F!'b_gmz
ActiveDocument.Styles.Add Name:="QLNU目录项", Type:=wdStyleTypeParagraph Td"f(&Hk&
ActiveDocument.Styles.Add Name:="QLNU章节标题", Type:=wdStyleTypeParagraph Ngh9+b6[
ActiveDocument.Styles.Add Name:="QLNU一级标题", Type:=wdStyleTypeParagraph -i?!em'J
ActiveDocument.Styles.Add Name:="QLNU二级标题", Type:=wdStyleTypeParagraph pS*vwYA
ActiveDocument.Styles.Add Name:="QLNU三级标题", Type:=wdStyleTypeParagraph !cp
,OrO\
ActiveDocument.Styles.Add Name:="QLNU四级标题", Type:=wdStyleTypeParagraph ).-B@&Eu%
ActiveDocument.Styles.Add Name:="QLNU正文", Type:=wdStyleTypeParagraph A*MlK"
rJ9a@n,
ActiveDocument.Styles.Add Name:="QLNU表格标题", Type:=wdStyleTypeParagraph b_\aSEaTT
ActiveDocument.Styles.Add Name:="QLNU表格首行", Type:=wdStyleTypeParagraph <\2,7K{{+;
ActiveDocument.Styles.Add Name:="QLNU表格内容", Type:=wdStyleTypeParagraph V:My1R0
ActiveDocument.Styles.Add Name:="QLNU图片标题", Type:=wdStyleTypeParagraph GG%j+Ed
ActiveDocument.Styles.Add Name:="QLNU图片段落", Type:=wdStyleTypeParagraph X^fMt]
>8>`-
ActiveDocument.Styles.Add Name:="QLNU参考文献", Type:=wdStyleTypeParagraph
]| ~],\
On Error GoTo 0 F/&Z1G.
DoEvents EiIbp4*e
)}n`MRDB
'BaseStyle y\r8_rBo
ActiveDocument.Styles("BaseStyle").AutomaticallyUpdate = False n1.]5c3p
With ActiveDocument.Styles("BaseStyle").Font tC-(GDGy5
.NameFarEast = "宋体" K^s!0[6
.NameAscii = "Times New Roman" uK}k]x\z
.NameOther = "宋体" ?s
p
.Size = 10.5 R;'Pe>
.Bold = wdUndefined ihf5`mk/$
.Italic = wdUndefined h"]v+u`!SM
.Subscript = wdUndefined 6D3fk
vcZ
.Subscript = wdUndefined V0ulIKck
f:Ju20D
.Underline = wdUnderlineNone RK"dPr
.UnderlineColor = wdColorAutomatic 3V LwMF?
.StrikeThrough = False ZZzf+F)T
.DoubleStrikeThrough = False FeLWQn/aV6
9[6xo!
.Outline = False q.uIZ
.Emboss = False _%z)Y=Q
.Shadow = False 4vp,izNW
.Hidden = False \W}?4kz
.SmallCaps = False f=g/_R2$xN
.AllCaps = False WR gAc%
.Color = wdColorAutomatic aq,&W
q@
.Engrave = False ZDcv-6C)B
.Scaling = 100 /Q})%j1S0
.Kerning = 1 )#IiHB
F
.Animation = wdAnimationNone i n
F&Pv