进行如下改动后,单击按钮无法运行!不知道什么地方出现问题?
Dim app As New MSWord.Application
try
Dim fileName = "D:\练习\选择题.docx"
Dim doc = app.Documents.Open(fileName)
Dim p As MSword.Paragraph, str1 As String, str2 As String,A As Integer,B As Integer
For Each p In Doc.Paragraphs
str1 = Left(p.Range, 5)
str2 = Left(p.Range, 4)
If str1 = "【选择题】" Then
A = p.Range.Start
End If
If str2 = "【解析】" Then
B = p.Range.End
Else
GoTo 100
End If
Doc.Range(A + 6, B).Copy
app.Documents.Add
doc.Selection.Paste
doc.Selection.TypeBackspace
doc.SaveAs2("D:\练习\" & "x" & Left(doc.Paragraphs(1), 1) & ".docx")
doc.SaveAs2("D:\练习\" & "x" & Left(doc.Paragraphs(1), 1), 10)
doc.Close(0)
100:
Next
catch ex As exception
msgbox(ex.message)
finally
app.Quit
End try