Word文档正文中有多个注释,其中的注文都使用【】表示。请教如何将所有这些注释同时转换为脚注?
网上有教的https://www.renrendoc.com/paper/192765314.html,但照着抄了一段代码没有成功,提示运行错误4120,参数无效,请问怎么解决呢
Sub AAA
Dim myRange As Range, NtRange As Range, strNT As String
Application.ScreenUpdating=False
Set myRange=ActiveDocument.Content
NF: With myRange.Find
.Text = "【*】"
.MatchWildcards=True
Do While .Execute=True
Set NrRange=ActiveDocument.Range(myRange.Start, myRange.Start)
strNT=myRange.Text
myRange.Delete
ActiveDocument.Footnotes.Add NtRange, strNT
myRange.SetRange myRange.End, ActiveDocument.Content.End-l
GoTo NF
Loop
End With
Application.ScreenUpdating=True
End Sub
懒得调试了,帮你用AI生成了一个,反正我能用
Sub 宏1()
Dim rng As Range
Dim findRange As Range
Dim strPattern As String
Dim strText As String
' 定义要查找的文本模式
strPattern = "【*】"
' 创建一个范围对象
Set rng = ActiveDocument.Content
Set findRange = rng.Duplicate
' 进行查找
With findRange.Find
.ClearFormatting
...
' 循环查找并替换
Do While .Execute
If findRange.Text <> "【" & Chr(42) & "】" Then
strText = Trim(findRange.Text)
findRange.Footnotes.Add Range:=findRange, Text:=strText ' 将找到的文本添加为脚注
findRange.Text = ""
End If
Loop
End With '
Sub ConvertCommentsToFootnotes()
Dim Comment As Comment
For Each Comment In ActiveDocument.Comments
Dim rngComment As Range
Set rngComment = Comment.Scope
rngComment.Collapse wdCollapseStart
rngComment.FormattedText = Comment.Range.FormattedText
rngComment.End = rngComment.End - 1 '去掉注释标记
rngComment.InsertFootnote ReferenceText:="自动转换的脚注", _
FootnoteType:=wdFootnote, _
Position:=wdBottomOfPage
Comment.Delete
Next Comment
End Sub