Results 1 to 12 of 12
  1. #1
    New Lounger
    Join Date
    Sep 2008
    Location
    Atlanta, GA USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find/Replace after Superscript (2007)

    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?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find/Replace after Superscript (2007)

    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.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Find/Replace after Superscript (2007)

    Try this. I don't know whether it is supported in Word 2007, but it works in Word 2003.
    1. <LI>Open the "special" Footnotes pane. To do this:
      *
      <UL><LI>Make sure the document you want to search is active
      <LI>Press Alt+F11 to open the Visual Basic Editor
      <LI>If you do not see a blank area labeled Immediate, press Ctrl+G to open the Immediate window
      <LI>Paste the following line of code into the Immediate window and then press Enter at the end to execute it

      <code>ActiveDocument.ActiveWindow.View.SplitSpecia l = wdPaneFootnotes</code>

      <LI>Close the Immediate window and VBE. When you return to your document, the Footnotes pane should be displayed
      *
    <LI>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"
    *
    <LI>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?

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Find/Replace after Superscript (2007)

    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

  5. #5
    Star Lounger
    Join Date
    May 2007
    Location
    Seattle, Washington, USA
    Posts
    85
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Find/Replace after Superscript (2007)

    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?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find/Replace after Superscript (2007)

    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

  7. #7
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Find/Replace after Superscript (2007)

    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

  8. #8
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Find/Replace after Superscript (2007)

    Thanks, I learn something new every day.

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

    StuartR

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find/Replace after Superscript (2007)

    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.

  10. #10
    New Lounger
    Join Date
    Sep 2008
    Location
    Atlanta, GA USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find/Replace after Superscript (2007)

    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.

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find/Replace after Superscript (2007)

    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.

  12. #12
    New Lounger
    Join Date
    Sep 2008
    Location
    Atlanta, GA USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find/Replace after Superscript (2007)

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •