P
Paul Malfait
Hello,
I'm looking for a way to insert text into headers and textboxes with a
macro.
I've read a lot about replacing text everywhere in a document as decribed in
http://word.mvps.org/FAQs/MacrosVBA/FindReplaceAllWithVBA.htm , but that
doesn't solve my problem.
I want to put variable text into headers etc. depending on certain codes I
put there before, formatted as ##001, ##002, ##003 etc.
So I want to search for a '##'-string, then select the next 3 characters,
and depending on the value of these chars replace the 5-char string (##001)
by a text that is present in memory.
When I do this in the main text I can use Selection.Find to search for the
## and the Selection.Moveright to select the next 3 characters, so I have
no problem there to delete the selected text and insert new text.
But when I have to loop through the StoryRange to scan all headers,
textboxes, etc. I don't know how to select text in there. It is as if the
cursor stays in the main text, and if I try to select text in the header
with Selection.Moveright (after having found the ##-code), the selection is
extended in the main text instead.
I hope anyone understands my problem and can help me.
Tnx
Paul Malfait
I'm looking for a way to insert text into headers and textboxes with a
macro.
I've read a lot about replacing text everywhere in a document as decribed in
http://word.mvps.org/FAQs/MacrosVBA/FindReplaceAllWithVBA.htm , but that
doesn't solve my problem.
I want to put variable text into headers etc. depending on certain codes I
put there before, formatted as ##001, ##002, ##003 etc.
So I want to search for a '##'-string, then select the next 3 characters,
and depending on the value of these chars replace the 5-char string (##001)
by a text that is present in memory.
When I do this in the main text I can use Selection.Find to search for the
## and the Selection.Moveright to select the next 3 characters, so I have
no problem there to delete the selected text and insert new text.
But when I have to loop through the StoryRange to scan all headers,
textboxes, etc. I don't know how to select text in there. It is as if the
cursor stays in the main text, and if I try to select text in the header
with Selection.Moveright (after having found the ##-code), the selection is
extended in the main text instead.
I hope anyone understands my problem and can help me.
Tnx
Paul Malfait