Deleting full stop/period at the end of footnotes

A

andreas

Dear Experts:

I would like to delete any full stops at the end of footnotes with the
following exception.

If the footnote ends in 'Space & f & Full Stop', the full stop is not
to be deleted as in:
...... Page 13 f.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
 
L

Lene Fredborg

The following macro should do what you describe:

Sub DeletePeriodsInFootnotes()

Dim oFootnote As Footnote
Dim nCount As Long

nCount = 0
For Each oFootnote In ActiveDocument.Footnotes
With oFootnote.Range
'Delete last character in case of a period
'however, skip if the footnote ends with " f."
If Right(.Text, Len(" f.")) <> " f." And .Characters.Last = "."
Then
.Characters.Last.Delete
'Count deletions
nCount = nCount + 1
End If
End With
Next oFootnote

MsgBox nCount & " periods deleted from footnotes."

End Sub

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
A

andreas

The following macro should do what you describe:

Sub DeletePeriodsInFootnotes()

    Dim oFootnote As Footnote
    Dim nCount As Long

    nCount = 0
    For Each oFootnote In ActiveDocument.Footnotes
        With oFootnote.Range
            'Delete last character in case of a period
            'however, skip if the footnote ends with " f."
            If Right(.Text, Len(" f.")) <> " f." And .Characters.Last = "."
Then
                .Characters.Last.Delete
                'Count deletions
                nCount = nCount + 1
            End If
        End With
    Next oFootnote

    MsgBox nCount & " periods deleted from footnotes."

End Sub

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word









- Show quoted text -

Hey Lene,

thank you very much for your quick reply and sophisticated code. It is
running as desired. Great job, as always from your side.
But I am afraid to say that I forgot to add that the footnotes could
also end in expressions like "Page 13 ff." and not only "Page 13 f." ,
i.e. there could be occurrences of "double f" at the end.
Is it possible to consider this in your code as well. I hope so.

Best Regards, Andreas
 
L

Lene Fredborg

Hi Andreas,

You only need to replace the line:

If Right(.Text, Len(" f.")) <> " f." And .Characters.Last = "."
Then

with the following line:

If Right(.Text, Len(" f.")) <> " f." And Right(.Text, Len("
ff.")) <> " ff." And .Characters.Last = "." Then

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
A

andreas

Hi Andreas,

You only need to replace the line:

            If Right(.Text, Len(" f.")) <> " f." And .Characters.Last = "."
Then

with the following line:

            If Right(.Text, Len(" f.")) <> " f." And Right(.Text, Len("
ff.")) <> " ff." And .Characters.Last = "." Then

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word








- Show quoted text -

Hey Lene,

great, this did the trick. Thank you so much for your valuable and
professional help, Regards, Andreas
 
L

Lene Fredborg

You are welcome. I am glad I could help.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top