||Carlos J. Quintero (Microsoft MVP)
||Microsoft Visual Studio .NET 2002
||Microsoft Visual Studio .NET 2003
If you have a document with two windows open (such as a code window and a designer
window), the Document.ActiveWindow property returns the first window which was
opened for the document, not the active one.
This is a bug of Visual Studio .NET 2002/2003. It was fixed in Visual Studio
Steps to reproduce the problem:
- Create a macro with this code:
|Language: VB.NET|| Copy Code (IE only)|
Dim objDocument As Document
Dim objWindow As Window
objDocument = DTE.ActiveDocument
If Not (objDocument Is Nothing) Then
objWindow = objDocument.ActiveWindow
If Not (objWindow Is Nothing) Then
MessageBox.Show("Active Window: " & objWindow.Caption)
- In the IDE, create a Windows Form application and open the code window
"Form1.vb" and the design window "Form1.vb [Design]", in this order.
- Ensure that the "Form1.vb [Design]" window is the active one and execute
the macro. Unexpectedly, you get that the active window is the code window
"Form1.vb" instead of the design window "Form1.vb [Design]". This happens both
in MDI mode and in Tabbed mode.
Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this