Remove whitespace in footnotes fails

J

John

I am trying to remove all whitespace from the end of a footnote in Word 2007.

I create a footnote in a new document with lots of space on the end: "My
footnote "
I turn on the reveal codes/show marks (backwards P in ribbon).

I run this macro. Every space is removed except for the last one! Why??

(I could Trim the Range.Text, but that removes character styles as well which
I don't want to do)


Sub TrimSpaces()

lChr = ActiveDocument.Footnotes(1).Range.Characters.Last
cnt = 0
While lChr = Chr(32)
ActiveDocument.Footnotes(1).Range.Characters.Last.Delete
If cnt > 50 Then Exit Sub
cnt = cnt + 1
Wend


End Sub
 
J

John

John said:
I am trying to remove all whitespace from the end of a footnote in Word 2007.

I create a footnote in a new document with lots of space on the end: "My
footnote "
I turn on the reveal codes/show marks (backwards P in ribbon).

I run this macro. Every space is removed except for the last one! Why??

(I could Trim the Range.Text, but that removes character styles as well
which I don't want to do)


Sub TrimSpaces()

lChr = ActiveDocument.Footnotes(1).Range.Characters.Last
cnt = 0
While lChr = Chr(32)
ActiveDocument.Footnotes(1).Range.Characters.Last.Delete
If cnt > 50 Then Exit Sub
cnt = cnt + 1
Wend


End Sub


I meant: (doesn't work)

Sub TrimSpaces()
lChr = ActiveDocument.Footnotes(1).Range.Characters.Last
cnt = 0
While lChr = Chr(32)
ActiveDocument.Footnotes(1).Range.Characters.Last.Delete
lChr = ActiveDocument.Footnotes(1).Range.Characters.Last
If cnt > 50 Then Exit Sub
cnt = cnt + 1
Wend


End Sub
 
J

John

Anyone? This is driving me nuts! :)



John said:
I meant: (doesn't work)

Sub TrimSpaces()
lChr = ActiveDocument.Footnotes(1).Range.Characters.Last
cnt = 0
While lChr = Chr(32)
ActiveDocument.Footnotes(1).Range.Characters.Last.Delete
lChr = ActiveDocument.Footnotes(1).Range.Characters.Last
If cnt > 50 Then Exit Sub
cnt = cnt + 1
Wend


End Sub
 

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