Hi,
I try to write a VS2008 macro that, for an open solution, opens one source file twice and selects different lines in the two windows for me to compare the code snippets. (I do so to inspect duplicate code that is found by another software...) Unfortunately, I cannot convince my macro to do so. Instead it will do the selections to the first window only.
I was hoping the following Visual Basic procedure would do the job:
Sub OpenSameDocumentTwiceButSelectDifferentLines(ByVal fileName As String) Dim fileItem As ProjectItem = DTE.Solution.FindProjectItem(fileName) 'Open the Document in two windows fileItem.Open() fileItem.Document.Activate() fileItem.Document.NewWindow() 'Retrieve windows Dim windows As Windows = fileItem.Document.Windows 'Select different lines in the two windows Dim winOne As Window = windows.Item(1) winOne.Activate() winOne.Selection.GoToLine(52) winOne.Selection.LineDown(True, 2) Dim winTwo As Window = windows.Item(2) winTwo.Activate() winTwo.Selection.GoToLine(200) winTwo.Selection.LineDown(True, 5) DTE.ExecuteCommand("Window.TileVertically") 'To conveniently see both End Sub
Any help will be appreciated.
Cheers, Stephan
P.S. I know I'm years too late and that macros aren't supported in newer version of Visual Studio.