1 | ' Copyright (c) 2016, Evgeny Panasyuk
|
2 |
|
3 | ' Permission is hereby granted, free of charge, to any person or organization
|
4 | ' obtaining a copy of the software and accompanying documentation covered by
|
5 | ' this license (the "Software") to use, reproduce, display, distribute,
|
6 | ' execute, and transmit the Software, and to prepare derivative works of the
|
7 | ' Software, and to permit third-parties to whom the Software is furnished to
|
8 | ' do so, all subject to the following:
|
9 | '
|
10 | ' The copyright notices in the Software and this entire statement, including
|
11 | ' the above license grant, this restriction and the following disclaimer,
|
12 | ' must be included in all copies of the Software, in whole or in part, and
|
13 | ' all derivative works of the Software, unless such copies or derivative
|
14 | ' works are solely in the form of machine-executable object code generated by
|
15 | ' a source language processor.
|
16 | '
|
17 | ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 | ' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 | ' FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
20 | ' SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
21 | ' FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
22 | ' ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
23 | ' DEALINGS IN THE SOFTWARE.
|
24 |
|
25 | ' e-mail: E?????[dot]P???????[at]gmail.???
|
26 |
|
27 | Option Explicit
|
28 |
|
29 | Dim filename, line, column
|
30 | Dim MSVS_versions, version
|
31 | Dim dte, fso, wshShell
|
32 | Dim fullpath
|
33 |
|
34 | filename = WScript.Arguments(0)
|
35 | line = WScript.Arguments(1)
|
36 | column = WScript.Arguments(2)
|
37 |
|
38 | MSVS_versions = Array _
|
39 | ( _
|
40 | "VisualStudio.DTE.7", _
|
41 | "VisualStudio.DTE.7.1", _
|
42 | "VisualStudio.DTE.8.0", _
|
43 | "VisualStudio.DTE.9.0", _
|
44 | "VisualStudio.DTE.10.0", _
|
45 | "VisualStudio.DTE.11.0", _
|
46 | "VisualStudio.DTE.12.0", _
|
47 | "VisualStudio.DTE.14.0", _
|
48 | "VisualStudio.DTE.15.0" _
|
49 | )
|
50 |
|
51 | On Error Resume Next
|
52 |
|
53 | For each version in MSVS_versions
|
54 | Err.Clear
|
55 | Set dte = getObject(,version)
|
56 | If Err.Number = 0 Then
|
57 | Exit For
|
58 | End If
|
59 | Next
|
60 |
|
61 | If Err.Number <> 0 Then
|
62 | Set dte = WScript.CreateObject("VisualStudio.DTE")
|
63 | Err.Clear
|
64 | End If
|
65 |
|
66 | Set wshShell = WScript.CreateObject("WScript.Shell")
|
67 | Set fso = WScript.CreateObject("Scripting.FileSystemObject")
|
68 | fullpath = fso.GetAbsolutePathName(filename)
|
69 |
|
70 | dte.MainWindow.Activate()
|
71 | dte.MainWindow.Visible = True
|
72 | dte.UserControl = True
|
73 | wshShell.AppActivate dte.MainWindow.Caption
|
74 |
|
75 | dte.ItemOperations.OpenFile fullpath
|
76 | dte.ActiveDocument.Selection.MoveToLineAndOffset line, column + 1
|
77 |
|
78 | if Err.Number <> 0 Then
|
79 | WScript.Quit Err.Number
|
80 | End If
|
81 |
|
82 | On Error Goto 0
|