Rpacing text with formfield textbox

R

Robert

I have text in a document "ccc" which I want to replace
with a formfield textbox using a macro. The text occurs
many times in the document. I can use find to find each
occurence but how do I replace the text with a formfield
textbox? Thanks.
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Robert,

Use:

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="ccc", Wrap:=wdFindContinue,
Forward:=True) = True
ActiveDocument.FormFields.Add Selection.Range,
wdFieldFormTextInput
Loop
End With


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
W

Word Heretic

G'day "Robert" <[email protected]>,

when you do a

SOMERANGE.Find.Execute replace:=wdreplaceOne

the found result's range is kept in SOMERANGE. The Find is like a
special move for the range object.

So, we know the range we want to insert a form field into... and
that's all we really to know so we can get straight into with a

ActiveDocument.FormFields.Add SomeRange,wdFieldFormTextInput

However, my suspicious nature with a small dash of psychic power
suggests to me this is probably not the best way to achieve your end
results. Post a new message with the Use Case and see if there's a
betterer way :)



Steve Hudson
Word Heretic Sydney Australia
Tricky stuff with Word or words

Email: WordHeretic at tpg.com.au


Robert was spinning this yarn:
 

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