簡體   English   中英

如何刪除 MS Word 尾注的前兩個單詞

[英]How to remove first two words of a MS Word Endnote

我有一個偉大的宏尾插入頁碼,以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

哪個處理來自的尾注

^1 Blah blah blah
^2 Blah blah blah 
^3 Blah blah blah

進入

^1 Page 2. Blah blah blah
^2 Page 23. Blah blah blah 
^3 Page 119. Blah blah blah

我現在需要第二個宏來通過刪除“Page nn -”來“撤消”更改,以便我可以重新運行宏以刷新頁碼。 我的想法是我需要選擇以“Page”開頭的每個尾注的前 3 個單詞,或者選擇直到第一個“-”字符索引的范圍? 我需要對上述宏進行哪些更改才能選擇和刪除添加的文本?

這應該可以完成工作。

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM