Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Removing space after footnote in notes

    I have some old code that doesn't seem to work any more. Anyone have a better approach? I'm wondering if there's I could use a range for that and how?

    Rem ******FINDING Space TO RIGHT OF NOTE NUM & DELETING******
    Rem Home
    Selection.GoTo What:=wdGoToFootnote, Which:=wdGoToFirst, Count:=1, Name:= _
    ""
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Find "^f ", 0
    BText "Removing the space after the note numbers"
    While Selection.Find.Found = True
    Rem GoRight 1
    Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
    SelectLeft 1
    If Selection.Range = " " Then Selection.Delete
    FindNext "^f ", 0
    Wend
    ActiveDocument.UndoClear

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    You seem to have lost a fair bit of code in translation. Try the following macro which takes a different look at the problem
    Code:
    Sub GoGo2()
      Dim aFN As Footnote, aRng As Range
      For Each aFN In ActiveDocument.Footnotes
        Set aRng = aFN.Range
        aRng.Collapse Direction:=wdCollapseStart
        aRng.MoveStart Unit:=wdCharacter, Count:=-1
        If aRng.Text = " " Then aRng.Text = ""
      Next aFN
    End Sub
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. The Following User Says Thank You to Andrew Lockton For This Useful Post:

    Yuwipi Woman (2016-11-17)

  4. #3
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    From what you've posted, it appears you're trying to delete spaces following the footnote references in the document body. For that you could use code like:
    Code:
    Sub Demo()
    Application.ScreenUpdating = False
    Dim FtNt As Footnote, Rng As Range
    For Each FtNt In ActiveDocument.Footnotes
      Set Rng = FtNt.Reference
      With Rng
        Do While .Characters.Last.Next = " "
          .End = .End + 1
        Loop
        .Start = .Footnotes(1).Reference.End
        .Text = vbNullString
      End With
    Next FtNt
    Application.ScreenUpdating = True
    End Sub
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. The Following User Says Thank You to macropod For This Useful Post:

    Yuwipi Woman (2016-11-17)

  6. #4
    Star Lounger
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Thanks Andrew! That worked perfectly.

    Do you have some suggestions on a source of information to brush up on using ranges in footnotes? I have a number of other, similar routines that remove tabs on either side of a footnote number, and remove a period after the footnote number I have yet to replace. This is one ugly macro that I'm working with. It originally started out in WordBasic. I'm trying to work every bit of old code out of it, as soon as I can.
    Last edited by Yuwipi Woman; 2016-11-17 at 18:00.

  7. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    I don't have any suggestions for information sources other than simply asking the question here or on other forums. What you are trying to do is somewhat odd and unlikely to have been addressed in more structured information sources, books or online tutorials.

    I just record macros to get some keywords I can fiddle with or use to ask 'Dr Google' and then play with the vba intellisense to find most things if I haven't read about it somewhere before. The more code you look at, the more you'll learn about clever ways to performing tasks.

    As you can see from comparing Paul's code with mine, Footnotes have a .Reference and a .Range. The .Reference property is where the number appears in your document body. The .Range property is where the actually footnote resides. Paul's code included a loop to remove multiple spaces whilst mine only looked for one instance of a space. You should be able to adapt ideas from both these macros to extend your own macros.
    Last edited by Andrew Lockton; 2016-11-17 at 23:06.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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