A personal repository of technical notes. - CSC

DTE.ActiveDocument.Selection Missing Inellisense in Macro

Problem
Can not access properties of Selection object through intellisense in VS macro using Visual Studio Automation and Extensibility.

Solution
To use the Selection property of a text file such as program source code, it must first be cast to a TextSelection:

VB.NET
Dim selection As TextSelection = CType(DTE.ActiveDocument.Selection, TextSelection)

C#.NET
TextSelection selection = (TextSelection)DTE.ActiveDocument.Selection;

References
Document.Selection Property (EnvDTE)
http://msdn.microsoft.com/en-us/library/envdte.document.selection(VS.80).aspx

No comments:

Post a Comment