Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace text using VB macro

Status
Not open for further replies.

autumnEND

Programmer
Nov 1, 2005
61
GB
Hi ive created a macro to search through a folder containing documents, im wanting to search through the documents and change a date within the files.

the document contains a release date Like :

Release Apr 06
but it could be :

Release May 06

so i need to search through the documents like this :

Release ???????

and once it finds the release date to replace the date to a set constant of "Jan 06"

here is part of the code :

'Replaces all release dates with the new date
With Selection.Find
.ClearFormatting
'We allow the replacement of 7 chrs
.Text = "Release ???????"
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
If .Found = True Then
With .Replacement
.ClearFormatting
.Text = m_dateReplacement
End With
blnFoundReleaseDate = .Found
.Execute Replace:=wdReplaceAll, Wrap:=wdWrapAlways
End If
.Execute Format:=False, Forward:=True
End With

for some reason when it finds a date that needs to be changed, it wont change it

any pointers would be greatly appreciated.

thanks
 
For VBA stuff you will probably do better in the VBA forum (forum707). This forum is for VB5/6 issues

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top