1
votes

I used a macro some time ago to find and replace words. Application(Microsoft Word 2010)

dim docPath As String
Dim myRange As Range
docPath = ActiveDocument.Path
Set myRange = ActiveDocument.Content

myRange.Find.Execute FindText:=findString, ReplaceWith:=replaceString,MatchWholeWord:=True, Replace:=wdReplaceAll

i want to achieve same functionality in vb.net bacuse i am making a add-in but i cant seem to find ActiveDocument.Content to set my range of document or ActiveDocument.Path to get the path of required document.

1

1 Answers

0
votes

It depends on what kind of add-in you are building. In a VSTO add-in, you could use Globals.ThisAddIn.Application.ActiveDocument instead of ActiveDocument.