我一直在使用下面链接的代码从 word 文档中获取信息并创建一个新的 Excel 文档,其中它在第一列中插入脚注引用,在第二列中插入脚注的页面以及脚注的文本在第三列。
我现在想在 excel 文档中添加第四列,其中包含脚注引用的 word 文档中的句子。
想不通,求救?
抱歉,如果这很简单,VBA 不是我几乎不知道的语言!
这是所有感兴趣的人的更新代码......我想这对制作研究书籍和论文的人来说最有用
Dim xlapp As Object
Dim xlbook As Object
Dim xlsheet As Object
Dim i As Long, lognum As Long
Dim fnote As Footnote
On Error Resume Next
Set xlapp = GetObject(, "Excel.Application")
If Err Then
bstartApp = True
Set xlapp = CreateObject("Excel.Application")
End If
On Error GoTo 0
Set xlbook = xlapp.Workbooks.Add
Set xlsheet = xlbook.Worksheets(1)
With xlsheet.Range("A1")
.Offset(0, 0).Value = "Foonote Ref"
.Offset(0, 1).Value = "Page"
.Offset(0, 2).Value = "Footnote Text"
.Offset(0, 3).Value = "Sentence"
i = 1
For Each fnote In ActiveDocument.Footnotes
Set aRange = fnote.Reference
aRange.MoveStart unit:=wdSentence, Count:=-1
aRange.MoveEnd unit:=wdSentence
.Offset(i, 0).Value = fnote.Index
.Offset(i, 1).Value = fnote.Range.Information(wdActiveEndPageNumber)
.Offset(i, 2).Value = fnote.Range.Text
.Offset(i, 3).Value = aRange.Text
i = i + 1
Next fnote
End With
xlapp.Visible = True
xlbook.Activate
Set xlapp = Nothing
Set xlbook = Nothing
Set xlsheet = Nothing
End Sub```