Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    7
    Thanked 0 Times in 0 Posts
    I have an old VBA macro for Word that processes the footnotes. For some reason, I can't get the same code to work in Word 2010. It simply doesn't work as it usually does. It does what it is supposed to do with the notes in the text section. I suspect this is because Word 2010 searches for footnotes and utilized the footnote pane differently.

    Here is a sample of the code I'm using:

    Code:
    Rem ******SEARCHES FOR PARAGRAPH TAB & REMOVES TAB******
    Home
    BText "Removing extra tabs in front of note numbers"
    With Selection.Find
        On Error Resume Next
        .Text = "^p^t"
        With .Replacement
            .Text = "^p"
        End With
        .Execute Format:=True, Replace:=wdReplaceAll
    End With
    ActiveDocument.UndoClear
    I've tried adding:

    ActiveWindow.View.SplitSpecial = wdPaneFootnotes

    But that doesn't fix it.

    Another section of code is:

    Code:
    Rem ******FINDING SPACE TO LEFT OF NOTE NUM & DELETING******
    Note = "^f"
    Find " " + Note, 0
    Rem Find " ^f", 0
    BText "Removing extra spaces from front of note numbers"
    While Selection.Find.Found = True
        GoLeft 1
        SelectRight 1
        Rem While Selection.Range = Chr$(32)
        While Selection.Range = " "
            Selection.Delete
            SelectLeft 1
        Wend
        GoRight 1
        FindNext " " + Note, 0
        Rem FindNext " ^f", 0
    Wend
    ActiveDocument.UndoClear

    Any help will be appreciated.

    Thanks!

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    If you step through the procedure using the debugging toolbar, can you find a step where VBA neither gives you an error nor behaves as expected?

    Did it work in Word 2007? There may have been some relevant changes in VBA. You can download a tool to analyze your code. More info: Microsoft Office Code Compatibility Inspector user's guide.

  3. #3
    Star Lounger
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Thanks for that information. It looks like it will be a big help.

    The code doesn't function in Word 2007 either, but it works in Word 2003.

    It doesn't throw an error, but it doesn't behave as expected. What it seems to do with the first sample is just select nearby text, but doesn't change it. It looks like it selects the entire pane and then moves on to the next procedure.

    The basic purpose of this macro is to remove spaces, tabs, periods, and advances, from either side of a footnote, so the correct formatting can be reapplied. Oddly, the code that replaces with the correct formatting works just fine:

    Code:
    Rem ******LOOP UNTIL NOTENUMB NOT FOUND*****
    ActiveWindow.View.SplitSpecial = wdPaneFootnotes
    
    Find Note, 0
    While Selection.Find.Found = True
        BText "Formatting note numbers for journal"
        GoLeft 1
        If (FnType = 3) Or (FnType = 4) Then
            ActiveDocument.Fields.Add Range:=Selection.Range, Type:=wdFieldAdvance, Text:="\r" + AdvBeforeFN
        Else
            Selection.TypeText Text:=Chr$(9)
            Rem Selection.TypeText Text:="^t"
        End If
        GoRight 1
        If (FnType = 2) Or (FnType = 4) Then
            Selection.TypeText Text:="."
        End If

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    It would be interesting to try to reproduce the error you're getting, but there's a lot of code here that's not recognizable as Word VBA, and won't compile - unless a lot of the statements here are calls to subprocedures/functions which are defined elsewhere:

    Is "Note" a variable that is declared elsewhere?

    Is "Find" a custom function or subprocedure that is defined elsewhere?

    Are "BTText", "GoLeft" and "GoRight" custom functions?

    Is FNType a custom enum?

    In order to test your code, it would be necessary for you to post all of the required variable declarations and custom subprocedures/functions, so the code will compile and run.

    Gary

  5. #5
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by Yuwipi Woman View Post
    I have an old VBA macro for Word that processes the footnotes. For some reason, I can't get the same code to work in Word 2010. It simply doesn't work as it usually does. It does what it is supposed to do with the notes in the text section. I suspect this is because Word 2010 searches for footnotes and utilized the footnote pane differently.
    ...
    Any help will be appreciated.

    Thanks!
    Hi Yuwipi Woman,

    Are you working in Print Layout view? You may find you need to be in that view for your code to work.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

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