I'm trying to write a simple visual studio 2010 macro to search the solution for a string (gotten from the clipboard)
what I have so far:
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module RecordingModule
Sub TemporaryMacro()
DTE.ExecuteCommand("Edit.FindinFiles")
DTE.Find.FindWhat = My.Computer.Clipboard.GetText()
DTE.Find.Target = vsFindTarget.vsFindTargetFiles
DTE.Find.MatchCase = True
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = True
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
DTE.Find.SearchPath = "Entire Solution"
DTE.Find.SearchSubfolders = True
DTE.Find.FilesOfType = ""
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResults2
DTE.Find.Action = vsFindAction.vsFindActionFindAll
If (DTE.Find.Execute() = vsFindResult.vsFindResultNotFound) Then
Throw New System.Exception("vsFindResultNotFound")
End If
DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close()
End Sub
End Module
unfortunately, it doens't work. When I try using it, I get a 'Value does not fall in expected range' error on the line 'DTE.Find.FindWhat = My.Computer.Clipboard.GetText()'. This is my first visual studio macro ever, so I'm kind of lost.