• Find/Replace after Superscript (2007)

    Author
    Topic
    #453996

    I have a very large document with more than 2,000 footnotes. For most of them, I placed 2 spaced after the footnote superscript which I would like to reduce to 1. However, I am afraid to do a simple Search/Replace of 2 spaces/1 space, since it may mess up section breaks and various other formatting issues. I tried the “Special” feature in the Search/Replace action. While it allows me to find superscripts followed by 2 spaces, it does not allow me to replace those 2 spaces with 1 without deleting the superscript. Do you have any advice?

    Viewing 4 reply threads
    Author
    Replies
    • #1125866

      Welcome to Woody’s Lounge!

      I don’t see why replacing two spaces with one would cause problems with section breaks etc. I’d try it to see if it works. Save the document before you do so; if things go wrong you can always undo the action or close the document without saving it.

    • #1125867

      Try this. I don’t know whether it is supported in Word 2007, but it works in Word 2003.

      1. Open the “special” Footnotes pane. To do this:
         

        • Make sure the document you want to search is active
        • Press Alt+F11 to open the Visual Basic Editor
        • If you do not see a blank area labeled Immediate, press Ctrl+G to open the Immediate window
        • Paste the following line of code into the Immediate window and then press Enter at the end to execute it

          ActiveDocument.ActiveWindow.View.SplitSpecial = wdPaneFootnotes

        • Close the Immediate window and VBE. When you return to your document, the Footnotes pane should be displayed
           
    • Click in the footnote pane and call up the Replace dialog. Click the More button to expand it and choose the Down option “just in case”
       
    • Run your replace for 2 spaces to 1. You can test by replacing with an otherwise unused character or set of characters first if you like.[/list]Any luck?
  • #1125869

    I can’t find a way to do exactly the replacement you want.
    You could replace 2 spaces with 1 space in text and use More> Format > Style > Footnote Text. This will avoid making any changes in the main document.

    StuartR

  • #1125888

    Are all of your footnotes only 1 paragraph by any chance?

    If so, Hans and you other macro writers — could a macro be written that would work thru the footnote pane by

    going to the end of each footnote paragraph, stepping forward 2, then deleting 1,

    then repeating thru to the end?

    • #1125920

      One could use this, even if there are multi-paragraph footnotes:

      Sub RemoveDoubleSpacesFromFootnotes()
      Dim ftn As Footnote
      For Each ftn In ActiveDocument.Footnotes
      If ftn.Range.Characters(1) = ” ” Then
      ftn.Range.Characters(1).Delete
      End If
      Next ftn
      End Sub

      • #1125925

        Hans,

        I think the requirement was to leave single spaces alone, and to replace double spaces with single spaces. So you would want something more like.

        Sub RemoveDoubleSpacesFromFootnotes()
        Dim ftn As Footnote
        For Each ftn In ActiveDocument.Footnotes
        If ftn.Range.Characters(1) = ” ” And ftn.Range.Characters(2) = ” ” Then
        ftn.Range.Characters(1).Delete
        End If
        Next ftn
        End Sub

        (I guess this might need a check to make sure there are at least two characters in the footnote, but the risk is low).

        StuartR

        • #1125926

          The first space after the footnote number is not included in ftn.Range. So if there is a single space after the footnote number, ftn.Range.Characters(1) will *not* be equal to a space.

          • #1125927

            Thanks, I learn something new every day.

            Two things today, one about footnotes and one about testing my theories before posting.

            StuartR

  • #1125945

    You all are great! Thanks for the quick replies. I miscommunicated what I am trying to do. I have a doctoral dissertation that is 271,000 words and is over 500 pages (A4) single spaced. There are approximately 2,000 footnotes. So, I am hesitant to do the Search/Replace 2 spaces with 1 given some possible formatting that may get messed up as a result. I would prefer not to have to go back and check every page and paragraph and section breaks for accuracy, since the document is so large. My problem is not with the footnotes themselves. Rather, it is with the footnote superscript in the Normal text. It is after those superscripts that I wish to replace 2 spaces with 1.

    • #1125950

      You can do that without a macro:
      – Select Edit | Replace…
      – Click More>>
      – Tick the “Use Wildcards” check box.
      – Enter the following in the Find what box:

      (^2 )( )

      – Enter the following in the Replace with box:

      1

      – Click Replace All. Or if you’d like to test a few instances first, click Find Next, then click Replace.

      Explanation: the code for a footnote marker is ASCII character 2. ^2 lets you search for ASCII character 2.
      The expression (^2 )( ) in the Find what box means that you search for a footnote marker followed by a space and another space, i.e. by 2 spaces. The brackets divide the search text into two parts that you can refer to in the Replace with box as 1 and 2.
      We just use 1 in the Replace with box, i.e. the first part: the footnote marker followed by a space. The second part (the second space) is discarded.

      • #1125956

        Hans, I tried what you suggested and it worked! Many thanks. Problem solved.

Viewing 4 reply threads
Reply To: Find/Replace after Superscript (2007)

You can use BBCodes to format your content.
Your account can't use all available BBCodes, they will be stripped before saving.

Your information: