Click here to Skip to main content
15,937,127 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I used a macro some time ago to find and replace words. Application(Microsoft Word)

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 bacuse i am making a add-in with advanced features(as target) but i cant seem to find ActiveDocument.Content to set my range of document or ActiveDocument.Path to get the path of required document.

Please guide. Thanks in advance

1 solution

Here - How to: Programmatically Define and Select Ranges in Documents[^] - you'll find what you're looking for...

Dim rng As Word.Range = Me.Application.ActiveDocument.Content

How To Build an Office COM Add-in by Using Visual Basic .NET [^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900