vba - 将脚注导出到新文档
问题描述
我需要 vba 代码将 MSWord 文档中的所有脚注复制到单独的文档中。我希望它在原始文档中使用相同的编号进行排序。
我已经尝试了以下代码,但它什么也没显示。
Dim s As String
Dim ftnt As Word.Footnotes
Dim doc As Word.Document
Dim xRange As Range
Dim countNum As Integer
Set xDoc = ActiveDocument
countNum = 0
Do Until countNum = ActiveDocument.Range.Information(wdNumberOfPagesInDocument)
Set xRange = ActiveDocument.Footnotes(countNum).Range
s = s & vbCr & countNum & vbTab & xRange
countNum = countNum + 1
Loop
Set doc = Documents.Add
doc.Range.Text = s
End Sub
提前致谢。
解决方案
找到了我的问题的答案。
我遇到了错误,因为页码超过了脚注编号。因此,迭代时出现了问题。
脚注长度为 ActiveDocument.Footnotes.Count
Sub SelectA11FootnoteTexts()
Dim s As String
Dim ftnt As Word.Footnotes
Dim doc As Word.Document
Dim xRange As Range
Dim countNum As Integer
Set xDoc = ActiveDocument
footNotesNum = xDoc.Footnotes.Count
countNum = 1
Do Until countNum > footNotesNum
Set xRange = xDoc.Footnotes(countNum).Range
s = s & vbCr & countNum & vbTab & xRange
countNum = countNum + 1
Loop
Set doc = Documents.Add
doc.Range.Text = s
End Sub
推荐阅读
- excel - 使用 awk 和 bash 将 Data.txt 转换为 data.csv
- prometheus - Prometheus:是否可以在 prometheus Web UI 中创建/配置警报组?
- java - 在 Spring @Query 中使用变量
- c# - 任何人都可以对我在执行 .net 控制台应用程序时收到的错误有所了解。(System.Runtime.InteropServices.COMException (0x80040111)
- css - 在 React 中覆盖 CSS
- python - 按月计算 Python 循环时间
- cocoa - 在 Cocoa 应用中管理多个非文档窗口
- uwp - 将 MPU6050 与 Windows 10 IoT (windows.devices.sensors) 集成
- python - 芹菜工人失败任务重新排队逻辑(RabbitMQ)
- python - 寻找支持阿拉伯语的 NLP 库