repeating a macro

P

Peter Lareau

I have an existing document in which the footnote numbers
are static, i.e., they don't change if the location of
the text containing the footnote is moved. (The
footnotes were created manually and are designated:
FR=#). I want to write a macro that will search for FR=#
and replace the # with the sequential number field. I am
able to write the macro that does this for any one
footnote. However, I don't know how to write the macro
so that it will replace all the footnotes in one
operation. The document contains more than 1,000
footnotes and I don't want to have to manually run the
macro 1,000+ times. Can anyone give me some direction?

Thanks in advance.
 
M

Mark Tangard

Hi Peter,

If these are actual Word-aware footnotes, you should be able
to loop through the footnotes collection and work on each
footnote's .Range (the note itself) and .Reference (the mark
in the text):

Dim fn As Footnote
For Each fn In ActiveDocument.Footnotes
:
: <--- your code here
: <--- perhaps set a range var to fn.Range
: <--- collapse it to the start, then
: <--- use [range].MoveEndUntil vbTab
: <--- (assuming a tab follows the mark)
: <--- to isolate the text that your macro
: <--- will replace with a SEQ field.
Next fn

I can only guess at the gyrations you'll need beyond this, but
this is generally how I'd approach it.

If your footnotes are *not* something Word 'knows' about, it
sounds like you'd want a Do While .Execute loop inside a Find
structure that handles all occurrences of the footnote flag
you've used. But I'm guessing this isn't the case, since you
would've previously had to set up each footnote's text in, say,
a floating textbox.... a thousand times. Eew.
 

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