Dim bContinue As Boolean nXU`^<nA
GZefeBi
Dim regEX As New RegExp + d?p? v
Dim paraCounter As Long '全局段落计数,仅在主程序中可读写,其它过程函数应为只读 4{PN9i
E
v2Ft=_*G|
Dim LastTitle0String As String, LastTitle0No As Long ;H' ,PjU
Dim LastTitle1String As String, LastTitle1No As Long ,xSNTOJ
Dim LastTitle2String As String, LastTitle2No As Long PHAM(iC&D
Dim LastTitle3String As String, LastTitle3No As Long >Hr&F
nh+
Dim LastTitle4String As String, LastTitle4No As Long PiwMl)E|!
Dim LastTitle5String As String, LastTitle5No As Long 1U)U {i7j
Dim LastTabelString As String, LastTableNo As Long @\*`rl]
Dim LastFigureString As String, LastFigureNo As Long u~O9"-m !V
Lm-f0\(
Dim strSeperator As String PJfADB7Y
Rb/|ae
Sub ConvertWidth(fTEXT As String, rText As String)
Z;ze{Vb
Selection.Find.ClearFormatting 8SZZ_tS3r
Selection.Find.Replacement.ClearFormatting u0Q6+U
Selection.Find.Wrap = wdFindContinue 'zJBp 9a%
Me.txtStatus.Text = "转换全角数字字母" & fTEXT & "形式为半角" & rText 8}M-b6RV
DoEvents %I^schE*
Selection.Find.Execute findtext:=fTEXT, replacewith:=rText, Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue, MatchCase:=True HNUpgNi
End Sub *x!j:/S`n
"?*B2*|}`
Sub ClearDomain() i C)+5L#'
With Selection.Find L`2(u!i J
.ClearFormatting ?4`f@=}'K
.Replacement.ClearFormatting dI(1L~
.Wrap = wdFindContinue XY`{F.2h
Me.txtStatus.Text = "清除所有域代码" "xI70c{
DoEvents r+Pfq[z&
.Execute findtext:="^d", replacewith:="", Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue, MatchWildcards:=False }H
Ct=
W`
End With ,+P2B%2c
End Sub ;S_Imf0$v
F
,;B
Private Sub cmdCheck_Click() ya
c4\%ze
bContinue = True ]
/"!J6(e
Dim NoSeries1(1 To 16) As String @vc9L
Dim NoSeries2(1 To 16) As String H\%^n<]#
Dim NoSeries5(1 To 16) As String /wi*OZ7R
Dim NoSeriesRM(1 To 16) As String ~
|Nj+A
Dim paraTotal As Long, ParaText As String ge#0Q L0K
Dim ttString As String, ttNo As String *w#^`yeo
2S
Dim ShapeCounter As Long, ShapeHeight As Long, ShapeWidth As Long "F[e~S#V*
}j)][{i*x
Me.txtStatus.Visible = True awU!3)B
Me.lbParaType.Visible = True *Uw" `l
Me.cmdCheck.Enabled = False R@df~
PIHix{YR
=L\&}kzB
8l>7=~Egp
.DR*MQI9
Dim ParaType As String, rText As String +B '<0
~0@uR
Selection.WholeStory ([ jm=[E^
Selection.NoProofing = True P7 h^!a/
-<6b[YA
tm1 = Now mI,a2wqi
H'"=C&D~
ActiveWindow.View.Type = wdNormalView FfRvi8
>6KwZr BB
NoSeries1(1) = "一" >qy$W4
NoSeries1(2) = "二" u?4d<%5R!
NoSeries1(3) = "三" Mdw"^x$7
NoSeries1(4) = "四" qV#,]mX
NoSeries1(5) = "五" eK[9wEdn
NoSeries1(6) = "六" SgWLs
%B
NoSeries1(7) = "七" G_QV'zQ
NoSeries1(8) = "八" H2S/!Q;K
NoSeries1(9) = "九" xeB-fy)5+
NoSeries1(10) = "十" .: Zw6
NoSeries1(11) = "十一" RRb>]oD
NoSeries1(12) = "十二" 5_\1f|,
NoSeries1(13) = "十三" 2RU/oqmR
NoSeries1(14) = "十四" Pk3b#$+E
NoSeries1(15) = "十五" GU0[K#%
NoSeries1(16) = "十六" wzj:PS
79z/(T+
NoSeries2(1) = "㈠" Q<Q?#v7NX
NoSeries2(2) = "㈡" FrsXLUY
NoSeries2(3) = "㈢" yHo#v:>?p
NoSeries2(4) = "㈣" 'u#c_m!9
NoSeries2(5) = "㈤" *snY|hF
NoSeries2(6) = "㈥" Bh UGMK
NoSeries2(7) = "㈦" {zI>"%$u
NoSeries2(8) = "㈧" /EW=OZ/
NoSeries2(9) = "㈨" g [u*`]-;v
NoSeries2(10) = "㈩" D!DL6l`
A
I v
NoSeries5(1) = "①" TV Zf@U
NoSeries5(1) = "②" *qA:%m3
NoSeries5(3) = "③" "]bOpk T
NoSeries5(4) = "④" _<6E>"*m
NoSeries5(5) = "⑤" YJ!jdE}
NoSeries5(6) = "⑥" >~l^E!<i-u
NoSeries5(7) = "⑦" $ghlrV;:ct
NoSeries5(8) = "⑧"
7 \AoMk}
NoSeries5(9) = "⑨" (kVxa8 0
NoSeries5(10) = "⑩" }U^iVq*
vkLKzsN' ]
!GJT-[
NoSeriesRM(1) = "I" V
7oE\cxr
NoSeriesRM(2) = "II" 6/.kL;AI
NoSeriesRM(3) = "III" >l b9 j>
NoSeriesRM(4) = "IV" vX?C9Fr 2
NoSeriesRM(5) = "V" sis1Dh9:
NoSeriesRM(6) = "VI" k?}y@$[)
NoSeriesRM(7) = "VII" *`40B6dEr
NoSeriesRM(8) = "VIII" '5lwlF
NoSeriesRM(9) = "IX" Obx!>mI^6
NoSeriesRM(10) = "X" lMmP]{.>$
NoSeriesRM(11) = "XI" )b~+\xL5J
NoSeriesRM(12) = "XII" F]L96&
NoSeriesRM(13) = "XIII" 2c'<rkA
NoSeriesRM(14) = "XIV" ~bqw !rz
NoSeriesRM(15) = "XV" '};mBW4z
NoSeriesRM(16) = "XVI" 7*kTu0m
g;7W%v5wqk
i = MsgBox("为了你的数据安全,请使用单独保存的文件副本进行本操作。" & vbCrLf & "确定继续进行吗?", vbYesNo) E#E&z (G2
N(kSE^skOa
If i = vbNo Then D/ tCB-+
Exit Sub A6I^`0/
End If Y%!k'\n[2
z.!u<hy(
If Me.chkSuper.Value Then 4nXemU=
Me.txtStatus.Text = "检查修改所有的上标格式" 8{
+KNqz
lot;d3}
CheckSuperScript
%KPQ|^WE
o?d`o$
End If 3F8KF`*
x9o(q`N
If Me.chkStyle.Value Then mT>RQ.
Me.txtStatus.Text = "设置样式,请稍候...." o]eG+i6g]
DoEvents ?@^gpVK{
CeateOrModifyStyle gDjAnz#
End If :(K JLa]
6"9(ce
KX
RNopx3
IC6'>2'=T
ClearDomain B2:GGZ|jS
(~NR."s;
eF(oHn,
GBTwQYF
If Me.chkLIST.Value Then uvRX{q4
Me.txtStatus.Text = "将所有自动列表标题转化为人工标题形式" *Oq&g\K)
ck$>
ConvertListToOrdinary I%jlM0ZUI"
End If kZ0z]Y
GF36G?iEi
Ml
,in49
Dim pType As String, trimpTEXT As String t:P]G>)x|
If Me.chkNum.Value = True Then y[/:?O}g4
Me.txtStatus.Text = "转换全角数字形式为半角" jItVAmC=i
ConvertWidth "1", "1" B@ >t$jK
DoEvents h%5keiA
ConvertWidth "2", "2" VFK]{!C_
DoEvents *|^||
bd
ConvertWidth "3", "3" XaaR>HljJ
DoEvents T3Sz<K$E
ConvertWidth "4", "4" Z-L }"~
DoEvents hT%
>)71
ConvertWidth "5", "5" qN^]`M[ BY
DoEvents ,=[r6k<
ConvertWidth "6", "6" yuhY )T
DoEvents !Ld[`d.|R!
ConvertWidth "7", "7" JF'<""
DoEvents ^e]h\G
ConvertWidth "8", "8" HOr Xxxp1^
DoEvents /vPr^Wv
ConvertWidth "9", "9" I :8s 3;
DoEvents R1Fcd@DWD
ConvertWidth "0", "0" [[O4_)?el
DoEvents P\h1%a/D
ConvertWidth "a", "a" }&]T0U`@
DoEvents JH#p;7;
ConvertWidth "b", "b" 7e[&hea
DoEvents {Q)sR* d
ConvertWidth "c", "c" I0N~>SpZ5
DoEvents &srD7v9M8
ConvertWidth "d", "d" %v0;1m
DoEvents SB:z[kfz|
ConvertWidth "e", "e" ex.^V sf_
DoEvents w3;T]R*
ConvertWidth "f", "f" " eS-i@
DoEvents |9[)-C~N7
ConvertWidth "g", "g" !/]z-z2>
DoEvents 9RC:-d;;_
ConvertWidth "h", "h" wauM|/KG
DoEvents 4YXp,U
ConvertWidth "i", "i"
zj$Ve
DoEvents "$3~):o
ConvertWidth "j", "j" 4m%Yck{R
DoEvents ~lbm^S}-
ConvertWidth "k", "k" {rzQ[_)EC
DoEvents xiVbVr#[
ConvertWidth "l", "l" sRQ4pnnrn
DoEvents TpYdIt9#>
ConvertWidth "m", "m" KvjH\;78
DoEvents Pk6_ 1LV
ConvertWidth "n", "n" 59(kk;
ConvertWidth "o", "o" %r@:7/
ConvertWidth "p", "p" R8Dn
GR
ConvertWidth "q", "q" 4 g8t
ConvertWidth "r", "r" !{ !(yP_
ConvertWidth "s", "s" +E+I.}sOB
ConvertWidth "t", "t" _`Dz%(c
ConvertWidth "u", "u" U^Iq]L
ConvertWidth "v", "v" yQq|!'MK k
ConvertWidth "w", "w" `69xR[f
ConvertWidth "x", "x" CQA^"Ll
ConvertWidth "y", "y" {>3w"(f7o
ConvertWidth "z", "z" mj ,Oy
ConvertWidth "A", "A" ItE)h[86
ConvertWidth "B", "B" keJ-ohv)
ConvertWidth "C", "C" ?[.g~DK,
ConvertWidth "D", "D" P)[QC
ConvertWidth "E", "E" of'H]I
Z
ConvertWidth "F", "F" wS [k}
ConvertWidth "G", "G" (hIe!"s*
ConvertWidth "H", "H" .PCbGPbk
ConvertWidth "I", "I" M
(:_(4~
ConvertWidth "J", "J" lr[&*v?h
ConvertWidth "K", "K" {5SJ0'.B2g
ConvertWidth "L", "L" A{wk$`vH
ConvertWidth "M", "M" (\4YBaGd
ConvertWidth "N", "N" Yez
ConvertWidth "O", "O" XUK%O8N#9
ConvertWidth "P", "P" [9Hrpo]tU:
ConvertWidth "Q", "Q"
Q)
iN_ |
ConvertWidth "R", "R" ,
w,)n^
ConvertWidth "S", "S" d 1 O+qS
ConvertWidth "T", "T" KssIoP
ConvertWidth "U", "U" U8eU[|-8O/
ConvertWidth "V", "V" \wp8kSzC
ConvertWidth "W", "W" 7'7
o^>
!
ConvertWidth "X", "X" ]_hXg*?
ConvertWidth "Y", "Y" k~]\kv=
ConvertWidth "Z", "Z" lW
Fm>DiLY
ConvertWidth "^l", "^p" nIl<2H]F`
ConvertWidth "(", "(" [b
Em D
ConvertWidth ")", ")" kZQ$Iv+^(
#B__-"cRv
End If n*hRlL
5 HN
,y
With ActiveDocument 7??j}ob>
Dim tbl As Table 6W'2w?qj?4
For Each tbl In .Tables mFyYn,Mu|
tbl.Rows.Alignment = wdAlignRowCenter hOe$h,E']
tbl.Range.Font.NameFarEast = "楷体" zeuSk|O
tbl.Range.Font.NameAscii = "Times New Roman" `nL^]i
tbl.Range.Font.Size = 10.5 _<jccQ
Next uvA 2`%T/
Set tbl = Nothing XRn+6fn|
End With *
jl_,0g]
6M bMAh5>
R/&C}6Gn
With ActiveDocument 7mYBxE/
:Ek3]`q#
For i = 1 To .TablesOfContents.Count zU#
OjvNk
.TablesOfContents(i).Delete ;_1> nXh
Next u]<`y6=&C
mZ.E;X& ,*
?e23[
nVk]Qe
paraTotal = .Paragraphs.Count r]%.,i7~8
paraCounter = 1 ,]=Qgn
&.:yP3
LastTitle0No = 0 TzrU |D?
LastTitle1No = 0 .-:6L2
LastTitle2No = 0 X6oY-4O
LastTitle3No = 0 ^Y^5
@x=
LastTitle4No = 0 *4 Kc "M
LastTableNo = 0 u
&{|f
LastFigureNo = 0 {6*{P!H
S4%MnT6Uy
Dim Sec As Long 9z(h8H
BtP*R,>
Sec = InputBox("正文从第一节开始?", "节设置", 6) |bmc6G[
If Sec = 0 Then cKAZWON8;v
Exit Sub mh~n#bah
End If 9R|B 5.
fG /wU$B
k = 0 [~ |e:
Do While (paraCounter < paraTotal) And bContinue 3M{b:|3/q
k = k + 1 Ay\!ohIS3
If .Paragraphs(paraCounter).Range.Information(wdActiveEndSectionNumber) >= Sec Then :yAvo4)
Exit Do SFa^$w
End If nHB`<B
paraCounter = paraCounter + 1 "Oy&6rrr
If k Mod 20 = 0 Then 4\Cb4jq%/
Me.lbCounter.Caption = paraCounter "#`c\JuR]
DoEvents G/8G`teAZ
End If 7@i2Mz/eV
Loop :w4I+*
]
|y2cI,&
JmVha!<qk
Do While (paraCounter < paraTotal) And bContinue .w)T2(
|Vc:o_n7
ParaText = Trim(.Paragraphs(paraCounter).Range.Text) B'
D4]EB
ShapeHeight = 0 CYC6:g|)
ShapeWidth = 0 g$S<_$Iey
WR>2t&;E
CheckPara .Paragraphs(paraCounter).Range, ParaType, rText, ttString, ttNo, ShapeCounter, ShapeHeight, ShapeWidth qzu%Pp6If
Gp))1b';
Select Case ParaType eC-nV)]I9
Case "【】表格内容"
Uf-`g>
.Paragraphs(paraCounter).Style = "QLNU表格内容" &?7+8n&+
Case "章" JOx""R8T5
LastTitle0No = LastTitle0No + 1 (9D,Ukw
'新一章开始,复位其下属标题编号 B9h>
LastTitle1No = 0 :aMp,DfM]P
LastTitle2No = 0 cWL7gv\|
LastTitle3No = 0 0 }aw9g
LastTitle4No = 0 N+NS\Y5
jz$83TB-
k = Val(ttNo) 5$f*fMd;
If k = 0 Then '非数字编号章节 kx3]A"]>'
If ttNo <> NoSeries1(LastTitle0No) Then h>K%OxR
rText = "第" & NoSeries1(LastTitle0No) & ttString HUY1
nb=
Me.ErrMsg.AddItem "章节编号错误:" & ParaText Hy1f,D
End If Jx= v6==7
Else Q_n9}LanP
If Val(ttNo) <> LastTitle0No Then wB W]w
rText = "第" & LastTitle0No & ttString o8S)8_3
Me.ErrMsg.AddItem "章节编号错误:" & ParaText siGt5RH*
End If ~TALpd
oNBYJ]t
End If 0)3*E)g{
9!|.b::
'章段落设置 (
j~trpe,
'字体大小:三号16磅小三号15磅四号14磅小四号12磅五号10.5磅小五号9磅 zf^F.wW
.Paragraphs(paraCounter).Style = "QLNU章节" L}%4YB
.Paragraphs(paraCounter).Range.Select 4kQL\Ld#E%
Selection.EndKey unit:=wdLine ppM^&6x^
tc = Replace(rText, vbCr, "") @T+pQ)0{{
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 1 ", PreserveFormatting:=False AT,?dxP J
Case "一级标题" \)T4NN
LastTitle1No = LastTitle1No + 1 Z= P=oldH
'新一级标题开始,复位其下属标题编号 %Tv^BYQAZ
LastTitle2No = 0 NYZI;P1DA
LastTitle3No = 0 dNcP_l/A
LastTitle4No = 0 5VPP 2;J
#&c}in"!
If ttNo <> NoSeries1(LastTitle1No) Then Nh|QYxOP
rText = NoSeries1(LastTitle1No) & "、" & ttString pxs`g&3yd
Me.ErrMsg.AddItem "一级标题编号错误:" & ParaText <ba+7CK]w
End If `=f1rXhI+1
RJZ4fl
b."1p7'
'一级标题段落设置 格式:一、标题内容 dCH(N_
.Paragraphs(paraCounter).Range.Text = rText D*#r
V
P
.Paragraphs(paraCounter).Style = "QLNU一级标题" jR&AQ-H&
.Paragraphs(paraCounter).Range.Select a"0'cgB}
Selection.EndKey unit:=wdLine %j?<v@y
tc = Replace(rText, vbCr, "") r` (U3EgP
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 1 ", PreserveFormatting:=False 1~P ^g`
Case "二级标题" &tE#1<k
LastTitle2No = LastTitle2No + 1 O}_Z"y
'新二级标题开始,复位其下属标题编号 R?[KK<sWWe
LastTitle3No = 0 zos#B30
LastTitle4No = 0 nLjo3yvV..
~WG#Zci-
If ttNo <> NoSeries1(LastTitle2No) Then lGP'OY"Q
rText = "(" & NoSeries1(LastTitle2No) & ")" & ttString +Udlt)H
ErrMsg.AddItem "二级标题编号错误:" & ParaText L1E\^)
End If B%Spmx8
4d0<uB&v'
'二级标题段落设置 格式:(一)、标题内容 BpKgUwf;C
.Paragraphs(paraCounter).Range.Text = rText 1 ~#p3)B
.Paragraphs(paraCounter).Style = "QLNU二级标题" i&?do{YQ)
6?c(ue iL[
.Paragraphs(paraCounter).Range.Select D2}nJFR
]
Selection.EndKey unit:=wdLine Zcn,_b7
tc = Replace(rText, vbCr, "") M0zlB{eH
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 2 ", PreserveFormatting:=False .4wp
*n%J#[e(
Case "三级标题" ROHr%'owgL
LastTitle3No = LastTitle3No + 1 \
>(;t#>
'新三级标题开始,复位其下属标题编号 ?#917M
LastTitle4No = 0 nY<hfqof
%L$P']%t@
If Val(ttNo) <> LastTitle3No Then y(RK
|r
rText = LastTitle3No & ". " & ttString nfMQ3KP
Me.ErrMsg.AddItem "三级标题编号错误:" & ParaText KI="O6 h
.v:K`y;f\(
End If #
5x[Z[m
'三级标题段落设置 格式:1. 标题内容 =j1rw
.Paragraphs(paraCounter).Range.Text = rText W=EvEx^?%
.Paragraphs(paraCounter).Style = "QLNU三级标题" H A(e
.Paragraphs(paraCounter).Range.Select ul$YV9[\
Selection.EndKey unit:=wdLine X pd^^
tc = Replace(rText, vbCr, "") Q!VPk~~(
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 3 ", PreserveFormatting:=False =1"8ua
Case "四级标题" DOm5 azO!>
LastTitle4No = LastTitle4No + 1 1(**JTe
V OViOD
If Val(ttNo) <> LastTitle4No Then %%w]-`^h,
rText = "(" & LastTitle4No & "). " & ttString ~IKPi==@,
ErrMsg.AddItem "四级标题编号错误:" & ParaText )d6Ya1vJH
hOSkxdi*^
End If cTeEND)
'四级标题段落设置 格式:(1). 标题内容 K}U}h>N
.Paragraphs(paraCounter).Range.Text = rText #ab=]}2W_g
.Paragraphs(paraCounter).Style = "QLNU四级标题" O2Mo ~}
.Paragraphs(paraCounter).Range.Select W@x
UR-}51
Selection.EndKey unit:=wdLine N5=;
PZub
tc = Replace(rText, vbCr, "") 7=ZB?@bU~
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="TC """ & tc & """ \l 4 ", PreserveFormatting:=False nEM>*;iE
ryq95<lF
Case "表格标题" @u2nG:FG
LastTableNo = LastTableNo + 1 a|im DY_-j
J$?*qZ(oO
If ttNo <> CStr(LastTableNo) Then 81|Xg5g)b
rText = "表" & LastTableNo & ". " & ttString AhARBgf<
ErrMsg.AddItem "表格编号错误:" & ParaText {>cO&eiCt
217KJ~)'
End If mSzBNvci
O`hOVHDQ
'表格名称段落设置 格式:表1. 表格名称 -)tu$W*
.Paragraphs(paraCounter).Style = "QLNU表格标题" $Q|t^(
xe = Replace(rText, vbCr, "") _KkLH\1g$
.Paragraphs(paraCounter).Range.Select dvi
L5Eaj
Selection.MoveEnd wdCharacter, -1 '选择范围包括行尾的换行符。 A8R}W=
Selection.Range.Text = xe ~a5p_x P
Selection.EndKey ,]'?Gd
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="XE " & """" & xe & """", PreserveFormatting:=False ?b~V uo
:,=no>mMx
Case "表格首行" ~sQN\]5VW
.Paragraphs(paraCounter).Style = "QLNU表格首行" Xo*=iD$Jys
Case "图片标题" /0mbG!Ac
LastFigureNo = LastFigureNo + 1 YQ_3[[xT
NVMhbpX6
If ttNo <> CStr(LastFigureNo) Then B&`hvR
rText = "图" & LastFigureNo & ". " & ttString XY8s \DK
ErrMsg.AddItem "表格编号错误:" & ParaText h*Y);mc$#
G8lR_gD"!
End If 5"5D(
'图片名称段落设置 格式:图1. 图名称 T}X#I'Z
.Paragraphs(paraCounter).Range.Text = rText V(Ps6jR"BS
.Paragraphs(paraCounter).Style = "QLNU图片标题" B;?
"R
.Paragraphs(paraCounter).Range.Select %Y` @>P'
Selection.EndKey unit:=wdLine t,.MtU>K@
xe = Replace(rText, vbCr, "") iG*/m><-
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="XE " & """" & xe & """", PreserveFormatting:=False E
VBB:*q6
Case "正文" 5B?>.4R
'正文名称段落设置 wNW9xmS
.Paragraphs(paraCounter).Style = "QLNU正文" :hG?} [-2
Case "文献条目" i(JBBE"
With .Paragraphs(paraCounter) 8_K22]c5
'.Range.Select !0~$u3[b
'Selection.ClearFormatting y.~y*c6,g
'.Range.Find.Execute findtext:=rText, replacewith:=strSeperator 'Replacetext 传回了编号及分隔符部分, 而StrSeperator传回了正确的格式与分隔符如“[15] ” XX,iT~+-
.Style = "QLNU参考文献" u4=j!Zb8}
End With cRX0i;zag
Case "图表注解" XnQo0
R.PW
With .Paragraphs(paraCounter) z1ltc{~Z
.Range.Font.NameFarEast = "楷体" oO|zRK1;/
.Range.Font.NameAscii = "Times New Roman" g@.RfX=
.Range.Font.Size = 9 '小5号字 PQsqi;=)
u><gmp&
.Alignment = wdAlignParagraphCenter D!~-53f@
.LeftIndent = 0 vvLm9Tw
.RightIndent = 0 # a
'h,
.FirstLineIndent = 0 hp}J_/+4n
.LineSpacing = 12 rs3Uk.Z^'
.LineSpacingRule = wdLineSpaceExactly */n)_
.LineUnitAfter = 0 ~n84x
.LineUnitBefore = 0 EW{z?/
.OutlineLevel = wdOutlineLevelBodyText /}Y>_87
.PageBreakBefore = False V$+xJ m
.RightIndent = 0 W$0<a@
.WordWrap = True })|+tZ
.LineUnitAfter = 0.5 5o5y3ibQ
|Q^Z
I
End With n}qHt0N
Case Else +'?p $@d
'不作处理 @
#}9?>UV
End Select XGEAcN
(KHTgZ6
'含有inlineshape的段落处理 Nf>1`eP
If ShapeHeight > 30 Then Gv}*Tw$
.Paragraphs(paraCounter).LineSpacingRule = wdLineSpaceSingle '对有图片的段落设置为单倍行距 `av8|;
End If A}sb2P
R R><so%
If (ShapeWidth + ShapeHeight) > 150 Then iZQwo3"8r
.Paragraphs(paraCounter).Style = "QLNU图片段落" m El*{]
End If Te~"\`omJ3
l/_3H\iM
'段落计数器递 {hX.R
paraCounter = paraCounter + 1 d(w
$! $"h
Me.lbCounter.Caption = "当前检测段落:" & paraCounter 3C8'0DB
Me.txtStatus.Text = ParaText Rv6{'\:
DoEvents 5DfAL;o!
Loop d^IOB
|6Q
End With a4X J0Tm
o*\kg+8
msg = "" dfe 9)m>
sD.bBz
For i = 0 To Me.ErrMsg.ListCount - 1 >UpTMEQ
msg = msg & vbCrLf & vbCrLf & Me.ErrMsg.List(i) Ay!=Yk^~
Next F9ry?g=h
5,'?NEyw
uYS?# g
vfJ}t#%UH
Me.txtStatus.Text = "格式化完成!" & vbCrLf & "开始时间:" & tm1 & vbCrLf & "结束时间:" & Now & vbCrLf & msg sf]y\_zU
Me.cmdCheck.Enabled = True UHz*Tfjb
Me.txtStatus.Visible = True k'wF+>
Me.lbParaType.Visible = False {>G\3|^D
E) >~0jv
bContinue = False O9]j$,i
End Sub 0yXUVKq3
0,(U_+n
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) > >wbyj8
Dim pTEXT As String -Xkdu?6Eh
]6<
/{b
pTEXT = ChKRange.Text zGu(y@o
@<\f[Znt
o
ParaType = "其它" 0b=OK0n!%
TitleString = pTEXT fEdQR->
TitleNo = "N/A" ~
@Ib:M
@dcT8 YC
shpCounter = ChKRange.InlineShapes.Count *L/_ v
If shpCounter <> 0 Then R)t"`'6|
MaxShpHeight = 0: TotalShpWidth = 0 j_\sdH*r
For i = 1 To shpCounter rSB"0W7
k = ChKRange.InlineShapes(i).Height f
5_n
2
l = ChKRange.InlineShapes(i).Width {!xPq%
If k > MaxShpHeight Then 8UoMOeI3
MaxShpHeight = k Nm#VA.~
End If 4-=> >#
P
TotalShpWidth = TotalShpWidth + l __$IbF5
Next `|i #)
If MaxShpHeight > 60 Or TotalShpWidth > 150 Then X",fp
Exit Sub dh%C@n:B
End If nbw&+dcJ8
End If tuK"}HepB
y yrCO"eh
'空行 tOwwgf
If Len(pTEXT) <= 2 Then t/_w}
Exit Sub )__vPPko i
End If \CB{Ut+s
UKQ,]VC
^DVr>u
'是否为表格中的文字 cg<10KT
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdWithInTable) Then qI<6% ^i
ParaType = "表格内容" 1&Rz'JQ+
k = ActiveDocument.Paragraphs(paraCounter).Range.Information(wdEndOfRangeRowNumber) ,Z#t-?
If k = 1 Then M
'W@K
ParaType = "表格首行" Vy{=Y(cpF2
End If 3`J?as@^8
Exit Sub LDW":k|
End If ?b:J6(-
X_|8CD-@6
'例外情况:脚注 ()K%Rn
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdInFootnote) Then e6k}-<W*q
ParaType = "脚注"
C+,;hj
Exit Sub X^?<, Y)1.
End If z['>`Kt
xzy7I6X
'例外情况:尾注 (zBa2Vmmv
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdInEndnote) Then ];^A8?
ParaType = "尾注" 8[ 1D4d
Exit Sub 0kpRvdEr-
End If `Ten2(D
`Qv7a
Y
If ActiveDocument.Paragraphs(paraCounter).Range.Information(wdInHeaderFooter) Then :HRJ49a
ParaType = "页眉页脚" abWmPi
Exit Sub B>t$Z5Q^X
End If on(F8%]zE
oGly|L>
9C$b^wHd
With regEX 95aa
.Global = True i=reJ(y-
4*lShkL
.Pattern = "^第([1-9]|1|2|3|4|5|6|7|8|一|二|三|四|五|六|七|八|九|十)章(、|\.|\s|。|.)+(.{1,30})$" 75@){ :
If regEX.Test(pTEXT) Then xg'z_W
ReplaceTEXT = regEX.Replace(pTEXT, "第$1章 $3") 4CS9vv)9R
TitleString = regEX.Replace(pTEXT, "$3") tk<dp7y7
TitleNo = regEX.Replace(pTEXT, "$1") "4H&wHhT!
ParaType = "章" KB7CO:
Exit Sub ,$mnD@)
End If 7s,IT8ii
2<yi8O\
.Pattern = "^(十一|十二|十三|十四|十五|十六|一|二|三|四|五|六|七|八|九|十)(、|\.|\s|。|.)+(.{1,40})$" &m`1lxT
If regEX.Test(pTEXT) Then Dz]&|5'N
ParaType = "一级标题" <m`HK.|~
regEX.Execute (pTEXT) +e%9P%[+
ReplaceTEXT = regEX.Replace(pTEXT, "$1、$3") [sTr#9Z
TitleString = regEX.Replace(pTEXT, "$3") z*l3O~mZ
TitleNo = regEX.Replace(pTEXT, "$1") xqO'FQO%
Exit Sub U{RW=sYB~9
End If A"\kdxC
;)5d
wq
'全角或半角括号中的数字 3otia;&B
.Pattern = "(^\(|()(十一|十二|十三|十四|十五|十六|一|二|三|四|五|六|七|八|九|十)(\)|))(、|\.|\s|。|.)*(.{1,40})$" b3
MgJT"mN
If regEX.Test(pTEXT) Then #wNksh/J^
ParaType = "二级标题" >yg mE`g
regEX.Execute (pTEXT) Y1H8+a5@
ReplaceTEXT = regEX.Replace(pTEXT, "($2)$5") AASw^A3p
TitleString = regEX.Replace(pTEXT, "$5") `z-4OJ8~
TitleNo = regEX.Replace(pTEXT, "$2") ,!|/|4vh
Exit Sub
A<r@,*(g
End If 2K!3+D"
y^pk)`y8
'阿拉伯数字 1. 2. K/+5$SjF
.Pattern = "^([1-9]|1|2|3|4|5|6|7|8|9|0){1,2}(、|\.|\s|。|.)+(.{1,80})$" q0.+ F4
If regEX.Test(pTEXT) Then bec n$R
ParaType = "三级标题" @ ILG3"
regEX.Execute (pTEXT) gf2l19aP
ReplaceTEXT = regEX.Replace(pTEXT, "$1. $3") '未进行全半角转换,如需要可分成两步分别检测 }qG{1Er
TitleString = regEX.Replace(pTEXT, "$3") B1JdkL 3h
TitleNo = regEX.Replace(pTEXT, "$1") nu}$wLM
Exit Sub ,
4jkTQ*@2
End If nE+sbfC
CwTx7
^qa
'全角或半角括号中的阿拉伯数字 yd`xmc)
.Pattern = "^(^\(|()([0-9]|0|1|2|3|4|5|6|7|8|9){1,2}(\)|))(、|\.|\s|。|.)*(.{1,80})$" Q{UR3U'Q
If regEX.Test(pTEXT) Then X +*@
ParaType = "四级标题" fr;>`u[;
regEX.Execute (pTEXT) K!5QFO4
ReplaceTEXT = regEX.Replace(pTEXT, "($2) $5") @ _U]U
TitleString = regEX.Replace(pTEXT, "$5") hkJ4,.
TitleNo = regEX.Replace(pTEXT, "$2") j@v*q\X&
Exit Sub e4y dn
End If 1@P/h#_Vr
$s4 rG=q
'表格名称
2+TCFpv
.Pattern = "^表(\d{1,2}-{0,1}\d{0,1})([、|\.|。|.|\s]{1,9})(.{1,120})$" o
<0 f
If regEX.Test(pTEXT) Then syA*!Up
ParaType = "表格标题" 92WvD
regEX.Execute (pTEXT) )~T)$TS
ReplaceTEXT = Trim(regEX.Replace(pTEXT, "表$1. $3")) 3)T'&HKQ
TitleString = Trim(regEX.Replace(pTEXT, "$3")) XN5EZ#
TitleNo = Trim(regEX.Replace(pTEXT, "$1"))
3p"VmO
strSeperator = Trim(regEX.Replace(pTEXT, "$2")) '不知道为什么,但是发现传回的replacetext在修改Paragraph对象的Range.Text后,表格标题就会落入第一个单元格中,所以,只能用Paragraph.Range.Find.Execute方法替换 a:Y6yg%1>
Exit Sub vmv
k
End If `ndesP
'49&qO5B
'图片名称
VD;Ot<%
.Pattern = "^图(\d{1,2}-{0,1}\d{0,1})(、|\.|\s|。|.)+(.{1,120})$" "L|Ew#
If regEX.Test(pTEXT) Then I0(BKM
p&