Problem with Find and Replace using word object

I created a word automation object in lotus script, and have some text entered in word. Now i want to find a particular word and replace it with some other word. It works easily in VB but with lotus script i am not able to do the same. Please let me know wht code should i put to get this right.

Subject: Problem with Find and Replace using word object

Folks,

After a lot of trial and error, it was really quite simple.

Dim x As Variant

FindStart:

Set x = objWord.ActiveDocument.Range(0,0)

While x.find.execute(“
”)

x.Text=Chr$(13)

Goto findstart

Wend

Hope this safes others all the effort that I just wasted.

Regards

Stephen

Subject: RE: Problem with Find and Replace using word object

Stephen,Hi, I did try with this, but for me does not works. Could you send me the full code for this ?

My challenge is to create, from a .dot attached in a Notes document, a .doc, but I need to find some words in the .doc document, and then, replace for values of the notes document.

Thanks for your help

Miguel Angel Villafuerte

México

ma@ddinsys.com; miguelangel_villafuerte@yahoo.com

msn: ddinsys@hotmail.com

Subject: Problem with Find and Replace using word object

Here’s what I did: Set selec = worddoc.Range(0,0) 'set the Selection object to start at the beginning of the Word doc

With selec.Find	'find within the selection

	.Text = "<Heading>"	'search for the pre-built flag which determines placement of the introduction

	.Forward = True

	.Format = False

	.MatchCase = False

	.MatchWholeWord = False

	.MatchWildcards = False

	.MatchSoundsLike = False

	.MatchAllWordForms = False

	.Execute

	selec.Text = header

End With

Hope this helps.

Subject: RE: Problem with Find and Replace using word object

Thanks for the code, but it doesnt replace the word though. Is there something else that i need to add to this

Subject: RE: Problem with Find and Replace using word object

It should if the variable “header” (in this case) has a value.

Subject: Problem with Find and Replace using word object

This is what i have coded right now, when i execute this code, it appends “text” at the end of the line, whereas what i need is to replace “test” with “text”.

Please let me knw if anything wrong with this.

Set mydoc = MyApp.documents

Call myDoc.add

myApp.selection.TypeText (“test one test great job if you can do it”)

Set selec = myApp.Selection 'set the Selection object to start at the beginning of the Word doc

Dim header As String

header = “text”

Set selec = myApp.Selection.range

With selec.Find 'find within the selection

.Text = “test” 'search for the pre-built flag which determines placement of the introduction

.Forward = True

.Format = False

.MatchCase = False

.MatchWholeWord = False

.MatchWildcards = False

.MatchSoundsLike = False

.MatchAllWordForms = False

.Execute

selec.Text = header

End With

Subject: RE: Problem with Find and Replace using word object

I wish I could be of more help, but I’m no expert (obviously). My code worked for Word 97, I think. Sorry it’s not working in your case.