Replace superscript of Footnote reference in the footnotes only

ε祈祈猫儿з 提交于 2021-01-29 09:23:55

问题


I am trying to convert the footnotes into a specific font style (Chicago Style). I have managed to change font of footnotes separately but I can't refer to the footnote reference number in the footnotes of the pages. I am trying to convert the superscript into a normal number and can't get the code to work for some reason. It keeps changing the superscripts in the rest of the body of the document which is not what I am looking for because reference number in body are kept superscripted. Any help would be appreciated. Thank you!

   With ActiveDocument.Styles("Normal").Font
        .Name = "Palatino Linotype"
        .Size = 11
    End With
    
    Dim afn As Footnote
    For Each afn In ActiveDocument.Footnotes
        With afn.Range
            .Font.Size = 8.5
            .Font.Name = "Palatino Linotype"
            .Text = .Text
        End With
    Next afn
    
    Dim f As Footnote

    For Each f In ActiveDocument.Footnotes
      With f.Range.Characters(1)
        .Font.Superscript = False
      End With
    Next
        
    'With Selection
       '.Paragraphs(1).Range.Font.Reset
       '.Paragraphs(1).Range.Characters(2) = ""
       '.InsertAfter "." & vbTab
       '.Collapse wdCollapseEnd
    'End With
        
    
    'For Each afn In ActiveDocument.Footnotes
        'With ActiveDocument.Content.Find
         '.ClearFormatting
         '.Replacement.ClearFormatting
         '.Font.Superscript = True
         '.Format = True
         '.Text = ""
         '.Replacement.Text = "^&"
         '.Replacement.Font.Superscript = False
         '.MatchWildcards = True
         '.Execute Replace:=wdReplaceAll
        'End With
    'Next afn
    
    
    'Make Footnotes non-superscripted
    'With ActiveDocument.Content.Find
        '.ClearFormatting
        '.Replacement.ClearFormatting
        '.Font.Superscript = True
        '.Format = True
        '.Text = ""
        '.Replacement.Text = "^&"
       ' .Replacement.Font.Superscript = False
      '  .MatchWildcards = True
     '   .Execute


回答1:


A Word document is constructed from a number of Story Ranges, one of which is the Footnotes Story. To make the footnote number non-superscript just in the footnotes you can execute a find and replace in the Footnotes Story as below.

Sub ApplyChicagoStyle()
   With ActiveDocument.StoryRanges(wdFootnotesStory).Find
      .Style = ActiveDocument.Styles(wdStyleFootnoteReference)
      .Replacement.Style = ActiveDocument.Styles(wdStyleFootnoteText)
      .Replacement.Font.Superscript = False
      .Format = True
      .Execute Replace:=wdReplaceAll
   End With
End Sub

You would need to run this after you have added all the footnotes to your document.




回答2:


Your post is ambiguous:

• Are you trying to modify the footnotes, or the footnote references?

• Does Chicago actually require a specific font for footnotes, or a different font for the footnote reference in the footer from the footnote reference in the document body? I cannot find any documentation that suggests that either proposition is the case.

If it's the footnotes you want to change, change the Footnote Style. No code required.

Alternatively, if you want to remove the superscripting from the footnote references in the footnotes, but not in the document body, you could use a Find/Replace there. As a macro, this would be:

Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.StoryRanges(wdFootnotesStory).Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "^2"
    .Replacement.Text = "^&"
    .Replacement.Font.Superscript = False
    .Forward = True
    .Format = True
    .Wrap = wdFindContinue
    .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub


来源:https://stackoverflow.com/questions/65785357/replace-superscript-of-footnote-reference-in-the-footnotes-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!