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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem replacing text in Word Document

Status
Not open for further replies.

jcarneir

Programmer
May 17, 2001
26
VE
Hi,
I have this working code to replace Text in word documents:
(objDoc is an object word)
objDoc.Select
With Selection.Find
.Text = "Old text"
.Replacement.Text = "New text"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

This code works but I tried it in another Pc getting the error '5' in line: .Text = "Old text"

Both Pc's have W2K, Office 2K and the vba code is running in access 2K. Indeed, both pc's have a copy of the same mdb file to ensure that both the code and the references are the same.

I appreciate any clue about this.
Thx
 
I found the solution. It's a bug with Office.
Here is the link:

There are two possible solutions:
1) Use late binding with word objects (This solutions didn't work for my problem)
2) Register again the msword lib with regtlib.exe (you must download the program).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top