VBA to insert reference page into MS word endnote

前端 未结 2 738
时光说笑
时光说笑 2021-01-24 09:45

Book endnotes often forgo superscript numbers for page numbers. E.g., instead of

Abe Lincoln was assassinated with a pistol.^33
                   :
33. A single         


        
2条回答
  •  礼貌的吻别
    2021-01-24 10:31

    Try the below VBA code:

    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(1).InsertBefore "Page " & CStr(curPageNumber) & " - "
    
    
    Next
    End If
    
    End Sub
    

提交回复
热议问题