[英]How to remove first two words of a MS Word Endnote
I got a great macro for inserting the page number to the beginning of an MS Word endnote here :我有一个伟大的宏尾插入页码,以MS Word的开始在这里:
Sub InsertPageNumberForEndnotes()
Dim endNoteCount As Integer
Dim curPageNumber As Integer
If ActiveDocument.Endnotes.Count > 0 Then
For endNoteCount = 1 To ActiveDocument.Endnotes.Count
Selection.GoTo What:=wdGoToEndnote, Which:=wdGoToAbsolute, _
Count:=endNoteCount
curPageNumber = Selection.Information(wdActiveEndPageNumber)
ActiveDocument.Endnotes(endNoteCount).Range.Select
ActiveDocument.Application.Selection.Collapse _
(WdCollapseDirection.wdCollapseStart)
ActiveDocument.Application.Selection.Paragraphs(1).Range.Characters(3)._
InsertBefore "Page " & CStr(curPageNumber) & ". "
Next
End If
End Sub
Which processes the endnotes from哪个处理来自的尾注
^1 Blah blah blah
^2 Blah blah blah
^3 Blah blah blah
Into进入
^1 Page 2. Blah blah blah
^2 Page 23. Blah blah blah
^3 Page 119. Blah blah blah
I now need a second macro to "undo" the changes by removing the "Page nn - " so I can rerun the macro to refresh the page numbers.我现在需要第二个宏来通过删除“Page nn -”来“撤消”更改,以便我可以重新运行宏以刷新页码。 My thinking is I need to select the first 3 words each end note that begins with "Page", or maybe select the range up to the index of the first "-" character?我的想法是我需要选择以“Page”开头的每个尾注的前 3 个单词,或者选择直到第一个“-”字符索引的范围? What change would I need to the above macro to select and delete the text added?我需要对上述宏进行哪些更改才能选择和删除添加的文本?
This should do the job.这应该可以完成工作。
Sub InsertPageNumberForEndnotes()
' 04 Oct 2017
Dim Note As EndNote
Dim Sp() As String
Dim n As Long
For Each Note In ActiveDocument.Endnotes
With Note.Range
' remove "vbTextCompare" to make the search case sensitive
n = InStr(1, .Text, "page", vbTextCompare)
If n Then ' you could make this "If n = 1"
m = InStr(1, Txt, ". ")
.Text = Mid(Txt, m + 2)
End If
End With
Next Note
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.