Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Find replace text in a text box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ocean - 27 Mar 2006 08:57 GMT
I need to use VBA to open a doc file find a placeholder in a text box and
then replace it with a date. Eg the text is XXXXXX. and this needs to be
replaced with date field. I can do this fine if the XXXXXX is in a normal
documnet, but when I try and do it for a text box it cant find it. Can anyone
please help?
Jezebel - 27 Mar 2006 10:39 GMT
Find and Replace finds text in a textbox if you set .Wrap = wdFindContinue
(equivalent to using 'ALL' in the Search drop down, as opposed to UP or
DOWN).

But an easier approach is to use a DocProperty field, then in code all you
need do is set the property and update fields.

>I need to use VBA to open a doc file find a placeholder in a text box and
> then replace it with a date. Eg the text is XXXXXX. and this needs to be
> replaced with date field. I can do this fine if the XXXXXX is in a normal
> documnet, but when I try and do it for a text box it cant find it. Can
> anyone
> please help?
Ocean - 27 Mar 2006 12:27 GMT
Thanks for this - can you explain this bit further :

But an easier approach is to use a DocProperty field, then in code all you
need do is set the property and update fields.

Many thanks

> Find and Replace finds text in a textbox if you set .Wrap = wdFindContinue
> (equivalent to using 'ALL' in the Search drop down, as opposed to UP or
[quoted text clipped - 9 lines]
> > anyone
> > please help?
Jezebel - 27 Mar 2006 22:22 GMT
1. Go to File > Properties. On the Custom tab add a property called whatever
you like (eg 'MyDate'). Assign a dummy value.
2. In the body of the document, wherever you want this value to appear,
insert a DocProperty field: {DocProperty MyDate}
3. In your code, set the property using

ActiveDocument.CustomProperties("MyDate") = "22-Mar-2006"
ActiveDocument.StoryRanges(wdTextFrameStory).Fields.Update

> Thanks for this - can you explain this bit further :
>
[quoted text clipped - 21 lines]
>> > anyone
>> > please help?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.