Invoking the Replace Dialog from code

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

Anyone know how to invoke the .NET Replace dialog thorugh code (say, from
within an addin)? More specifically, I'm trying to open the replace dialog
with some pre-set parameters (such as FindText and ReplaceWith) for the
user. I've tried executing Edit.Replace with just about every option but it
either displays without any options or remains hidden.

TIA
 
Hi Dan,

Do you mean something like this for example (from a macro, but you should be
able to do similar from an addin I guess):
Sub Test()
DTE.ExecuteCommand("Edit.Replace")
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.FindWhat = "\}[\n ]*else[\n ]*\{"
DTE.Find.ReplaceWith = "\}else\{"
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = False
DTE.Find.PatternSyntax =
vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
REM DTE.Find.Execute()
REM DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close()
End Sub

Cheers
Doug Forster
 
Back
Top