How to find ActiveDocument.Path and ActiveDocument.Content in VB.Net for Microsoft Word

1.2k Views Asked by At

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

There are 1 best solutions below

0
On

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.