|
下面这段代码运行以后总提示end if没有if块,我把我下面标着1到5的这段不运行了就不提示了,是不是if不能套着用的呀
Dim reg As Object, wdapp As Object
Dim wdoc, tmqw
Dim md
Set md = Sheet2.Cells.Find(m, , , xlWhole)
Set reg = CreateObject("vbscript.RegExp")
On Error Resume Next
Set wdapp = GetObject(, "word.application")
If Err.Number = 429 Then
MsgBox "没有进行选题"
End If
Set wdoc = wdapp.Documents("题目.doc")
tmqw = wdoc.Range
With reg
.Global = True
.Pattern = "\d+[\u4e00-\u9fa5]?-\d+(?=、)"
Set zfcz = .Execute(tmqw)
End With
For Each tmh In zfcz
xtmh = tmh + 1
tmhwz = zj & "-" & tmh
Set xlrng = Sheets("姓名").md.Row.Find(tmhwz.Value, , , xlWhole)
If xlrng Is Nothing Then
Sheets("姓名").Cells(md.Row, Columns.Count).End(xlToLeft).Offset(0, 1) = tmhwz
Else
sc = MsgBox(tmh & "已经做过是否删除", vbYesNo)
If sc = vbYes Then '1
With wdoc
Set myrange = .Content
myrange.Find.Execute FindText:=tmh & "、", Forward:=True
ks = myrange.Start
Set myrange = .Content
myrange.Find.Execute FindText:=xtmh & "、", Forward:=True
js = myrange.End
.Range(Start:=ks, End:=js - 3).Delete
End If '5
End If
Next
wjm = InputBox("另存为文件的名称") |
|