首页 > 解决方案 > 更改脚注的顺序

问题描述

我想更改文本中的脚注更具体地说,我想在这个概念中的脚注之后加上句号。在线似乎唯一的解决方案是使用宏,但我不知道从哪里开始。

我只发现这个脚本接近解决方案

Sub UpdateFootnotes()
'Update fields in all footnotes.
Dim doc As Document
Dim rng As Range
Set doc = ActiveDocument
If doc.Footnotes.Count <> 0 Then
'Select all footnotes.    
Set rng = doc.Footnotes(1).Range
rng.WholeStory
rng.Select
'Update all fields. 
Selection.Fields.Update
End If
End Sub

我需要为我的学士论文做这件事,它真的对我有很大帮助!

编辑:来自微软论坛中发布的答案here

标签: ms-word

解决方案


您找到的宏与更改脚注引用的位置无关;它只是更新脚注中的任何字段。

以下宏处理脚注和尾注。

Sub FootnoteEndnoteFix()
Application.ScreenUpdating = False
Dim FtNt As Footnote, EndNt As Endnote, Rng As Range
With ActiveDocument
  For Each FtNt In .Footnotes
    Set Rng = FtNt.Reference
    With Rng
      'Eliminate any spaces before the footnote
      While .Characters.First.Previous.Text = " "
        .Characters.First.Previous.Text = vbNullString
      Wend
      'Swap the footnote/punctuation, as applicable
      Select Case .Characters.First.Previous
        Case ".", ",", "!", "?", ":", ";"
          .InsertAfter .Characters.First.Previous
          .Characters.First.Previous.Text = vbNullString
          .Characters.Last.Font.Superscript = False
      End Select
    End With
  Next
  For Each EndNt In .Endnotes
    Set Rng = EndNt.Reference
    With Rng
      'Eliminate any spaces before the endnote
      While .Characters.First.Previous.Text = " "
        .Characters.First.Previous.Text = vbNullString
      Wend
      'Swap the endnote/punctuation, as applicable
      Select Case .Characters.First.Previous
        Case ".", ",", "!", "?", ":", ";"
          .InsertAfter .Characters.First.Previous
          .Characters.First.Previous.Text = vbNullString
          .Characters.Last.Font.Superscript = False
      End Select
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub

推荐阅读