|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
简单粗暴的在“你的代码基础上”改的!!!!!!!!!!!!!!!
Sub 宏1()
Dim oApp As Object
Dim oappwork, 接收表
Dim myStart&, Doc As Document, p As Range, s As Range
Set oApp = CreateObject("Excel.Application")
Set oappwork = oApp.Workbooks.Add
Set 接收表 = oappwork.Sheets(1)
接收表.Cells(1, 1) = "项目名称"
接收表.Cells(1, 2) = "成果简介"
Set Doc = ActiveDocument
Set p = Doc.Content: Set s = p.Duplicate
With s.Find
Do While .Execute("项目名称")
If Not s.InRange(p) Then Exit Do
n = n + 1
With s
If n > 1 Then
接收表.Cells(n, 1) = Doc.Range(myStart, .Start).Paragraphs(1).Range.Text
With Doc.Range(myStart, .Start).Find
If .Execute("成果简介*成果创新性", , , -1) Then
With .Parent
.Start = .Start + 5: .End = .End - 5
接收表.Cells(n, 2) = .Text
End With
End If
End With
End If
myStart = .Start: .SetRange .End, .End
End With
Loop
End With
If n > 0 Then
接收表.Cells(n + 1, 1) = Doc.Range(myStart, p.End).Paragraphs(1).Range.Text
With Doc.Range(myStart, p.End).Find
If .Execute("成果简介*成果创新性", , , -1) Then
With .Parent
.Start = .Start + 5: .End = .End - 5
接收表.Cells(n + 1, 2) = .Text
End With
End If
End With
End If
oApp.Visible = True
End Sub
|
|