![]() |
|
|
|
#1
|
||||
|
||||
|
The problem with your document is that it has trailing spaces & paragraph breaks formatted green. The following code revision will take care of that (plus tabs & line breaks):
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range, FtNt As Footnote
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Format = True
.Font.ColorIndex = wdGreen
.Wrap = wdFindStop
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
If .Characters.Last Like "[" & vbCr & vbTab & Chr(11) & Chr(160) & " ]" Then
.Characters.Last.Font.Reset
.End = .End - 1
End If
Set Rng = .Duplicate
.Collapse wdCollapseStart
Set FtNt = .Footnotes.Add(.Duplicate)
Rng.Start = FtNt.Reference.End
FtNt.Range.FormattedText = Rng.FormattedText
Rng.Delete
If .End = ActiveDocument.Range.End Then Exit Sub
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
Wow! This is truly amazing! It works perfectly. Thank you very much!
|
|
#3
|
|||
|
|||
|
Hi there!
Sorry for taking back an old thread. The macro below transforms text in green color into footnotes. Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range, FtNt As Footnote
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Format = True
.Font.ColorIndex = wdGreen
.Wrap = wdFindStop
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
If .Characters.Last Like "[" & vbCr & vbTab & Chr(11) & Chr(160) & " ]" Then
.Characters.Last.Font.Reset
.End = .End - 1
End If
Set Rng = .Duplicate
.Collapse wdCollapseStart
Set FtNt = .Footnotes.Add(.Duplicate)
Rng.Start = FtNt.Reference.End
FtNt.Range.FormattedText = Rng.FormattedText
Rng.Delete
If .End = ActiveDocument.Range.End Then Exit Sub
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
End Sub
This is normal text.[!This should be turned into a footnote.!] This is normal text. This is normal text... And so on. Is that possible? Thank's in advance, Thiago |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to change superscript footnotes into genuine Word footnotes
|
Knounte29 | Word VBA | 41 | 01-16-2020 04:48 PM |
Help with Tracking: Bold in body text, but not in Footnotes
|
Bobbety | Word | 3 | 05-17-2015 11:17 PM |
word 2007 - footnotes and text box
|
glggluig | Word | 1 | 08-10-2014 04:09 AM |
| All my footnotes turned to blue underlined text. | bww | Word | 0 | 07-11-2013 08:35 AM |
create footnotes from custom text
|
mosrozen | Word VBA | 2 | 06-14-2012 06:59 AM |