0

Can any one please tell, How to find a specific word in a word document and paste a word near to that using vba code?

I have already opened the document.So i just want to find the word and paste a word near to that. I have done this using movedown and moveright methods to go to that specific word.But it is more dependent on the position of cursor.

Thanks,

Bharathi

Bharathi
  • 11
  • 1

1 Answers1

0

I use this in access I don't know if it will work for you.

Dim mWord As Word.Application
Dim mDoc As Word.Document
Dim mRange As Word.Range

Set mDoc = mWord.Documents.Open("YourPath")
mDoc.SaveAs "Where you want to save"

Set mWord = New Word.Application
mWord.Visible = False

DoEvents
Set mRange = mWord.ActiveDocument.Content

mRange.Find.Execute FindText:=TextToFind1, ReplaceWith:=TextToFind1 & TextToReplace1, Replace:=wdReplaceAll
mRange.Find.Execute FindText:="TextToFind2", ReplaceWith:="TextToReplace2", Replace:=wdReplaceAll
Set mRange = Nothing

mDoc.Save

'Display
mWord.Visible = True

Shell "Explorer.exe /n,/e," & "DirectoryToOpen", vbNormalFocus

Good luck

FranckMetis
  • 113
  • 10
  • Hi FrankMatis, Thanks for your reply. Actually, i have to find the word and paste a word next to that and i dont want to replace that. Can you please suggest me some other way to done with that? – Bharathi Apr 12 '13 at 08:41
  • Well you could search for a word and replace the word and add what you want to add. I changed my answer to work better with your problem. (Is it your problem or you're problem I'm not really good in english.) – FranckMetis Apr 12 '13 at 11:21
  • Hi Frank, Thank you.I will try with this. – Bharathi Apr 13 '13 at 16:22
  • if i am your problem..i m sorry :) -Bharathi – Bharathi Apr 13 '13 at 17:12