Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

VS2008 Macro: How to open the same document in two windows and select different lines per window

$
0
0

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.


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>