Extensibility Overview

The development environment provides a fixed level of functionality and a select set of tools. You might find that you require some functionality or a tool that doesn't exist in the Integrated Development Environment (IDE), or you might find yourself repeating a simple task over and over. To address this issue with earlier versions, you might have purchased prefabricated controls or toolsets to augment the IDE. Now, you can create additions to our tools from within the environment using its extensibility object model.

Use objects from this model to construct add-ins — modular ActiveX components that connect to the IDE and provide added functionality. Add-ins can be constructed to work inside or outside the IDE, or both. They can automate repetitive tasks, monitor the IDE for the occurrence of certain events, act upon those events, and/or perform complex tasks. Add-ins can be activated through menu commands, toolbar buttons, or through Windows events.

Each of the development languages provides its own additions to the extensibility object model. You can write add-ins to automate the common IDE using the common environment's extensibility object model. You can also write add-ins to specific features in Visual J++ or any of the other development languages, using the object model provided for that language.


Extending the Development Environment

Extensibility is the capacity to extend or stretch the functionality of the development environment. Extensibility is not a new concept to development environments. Some language development packages give you the ability to add functionality to their user environments. However, the extent of control provided to you can be limited, or difficult to understand and implement.

The development environment provides you with a powerful, easy-to-understand modular system for customizing its environment through a programming interface known as the Extensibility object model. Its sole purpose is to allow you to "hook into" the workings of the development environment and create extensions known as add-ins. In addition to the object model provided by the common environment, each of the development languages provides an extensibility object model supporting the specific features of its environment.

The extensibility model consists of four related groups of individual code objects that control major facets of the common IDE. Each functional group enables you to create tools to customize the development environment and help you accomplish your programming tasks more quickly and easily. These groups are:

  • Window manipulation objects

  • Event objects

  • Add-in management objects

  • Project manipulation objects

Each group consists of one or more collections and objects which together contribute to a particular purpose. For example, the primary function of the events object group is to provide events occurring in the development environment. One object in this group is the CommandBarEvents object, which allows you to trap events occurring on menus and toolbars. Another is the BuildEvents object, which exposes events occurring at the beginning and end of solution builds.

What does all this mean to you? This means that you don't have to settle for the constraints of the programming environment or rely on third-party extensions that don't do exactly what you want them to do. You might, for example, create add-ins to:

  • Customize the development environment user interface. For example, you can create an enhanced version of the Project Explorer window where you can customize views, add or delete folders, navigate and view project elements, and so on.

  • Control projects. You can design an add-in that loads a group of projects, one after another.

  • Programmatically edit code. You can use an add-in to automatically add comments to certain lines of code.

  • Control windows. You can create an add-in that closes all currently open windows, or one that sets windows to predetermined sizes and locations.

These are just a few ideas. Add-ins give you the freedom to create custom programming solutions to save you time and help you become more productive. Just think of the possibilities!


Extensibility with the Environment

This group of objects helps you control and manipulate various elements within the development environment. Using these objects you can:

  • Add and invoke commands.

  • Add, delete or return lines of code from the text editor.

  • Set or return build properties.

  • Return information about the contents of the current selection.


Development Environment Extensibility Object Model

When driving through an unfamiliar city, it’s usually helpful to have a road map to find your way around. Consider this chapter your road map to the extensibility model. Studying and becoming familiar with it will make it quicker and easier for you to program the perfect add-in that does exactly what you need it to do.

Many objects in the model relate to each other for specific functional purposes, such as manipulating source code or connecting and using add-ins. In the diagram below, these related objects are grouped together.


Extensibility with Project Items

This group of objects helps you control and manipulate projects and project items in the development environment. Using these objects you can:

  • Add or delete projects in a solution.

  • Add or delete items within a project

  • Set or return properties of project items.


Extensibility with Windows

This group of objects helps you control and manipulate the various windows in the development environment. Using these objects you can:

  • Open and close environment windows.

  • Set or return window location and size.

  • Set or return window state (minimized, maximized or normal).

  • Get the extensibility object model for a tool window, such as the Task Lists object model.


Extensibility with Events

This group of objects provides events for elements in the development environment. Using these objects you can monitor or intercept the following types of events:

  • The beginning and end of the build process.

  • Clicks on the Office CommandBarControl object.

  • Clicks on commands in the environment.

  • Opening or closing a solution, and adding, renaming or deleting projects in the solution.


What is an Add-In

Add-ins are tools that you create programmatically using objects and collections in the extensibility model to customize and extend the development environment. In a sense, add-ins are time and labor saving automation tools that "snap-in" to the integrated development environment (IDE).

The primary goal of an add-in is to enable you to automate a task in the development environment that is difficult, or tedious and time consuming to accomplish manually. There are four types of add-ins: add-ins, Wizards, utilities, and builders:

  • Add-in is the generic term for any ActiveX DLL or Exe which supports the IDTExtensibility2 interface, and can be loaded by the development environment.

  • A Wizard is an ActiveX DLL or Exe which leads a user step-by-step through a task, often an especially complex or tricky one. Although they can be constructed any way you like, Microsoft implements its Wizards in a specific manner. A Microsoft Wizard consists of a number of frames, each frame containing an image in the upper left corner, a label description to the right of the image which may also contain instructions, and an optional area near the bottom in which other controls can be placed. You implement wizards using the IDTWizard interface.

  • A utility is an add-in, sometimes a rather large one, which doesn't necessarily require the environment to run. This means that it is compiled as an ActiveX executable, but it retains the ability to also be called as an add-in in the development environment.

  • A builder is a type of add-in that watches the IDE for user-triggered events, (adding a new component to the current project, adding a new control to the Toolbox, adding a new control to a form, and so on), and then reacts by bringing up a series of screens to help ease the task which raised the event. This type of add-in is generally not triggered by an explicit request on the part of the user - it is activated by some event. Builders also don't usually have a wizard-style interface.

Add-ins don't necessarily have to be visible — they can sit hidden in the background and respond to events such as the sizing of a window. Or they may be entirely visual; for example they may resize a group of like objects when the user sizes only one of the objects.

For More Information For information about initializing a new add-in, see Using Add-In Designer in the Visual Basic documentation. Also see the sample add-in written in Java in the Visual J++ Samples directory.


Objects that Allow You to Use Add-Ins

This group of objects helps you control and manipulate add-ins within the development environment. Using these objects you can return the following kinds of information:

  • The add-in's GUID.

  • Whether the add-in is connected.

Note You can use the IDTWizard object to implement wizards.


Registering an Add-In

In order to use an add-in and display it in the Add-In Manager, you must first register it on your machine.

Registering an add-in

  1. Copy the add-in to your machine.

  2. Register the component by running Regsvr32.exe on the add-in.

    Note This process registers the class ID (CLSID) and programmatic ID (progID), so that the add-in is CoCreatable.

  3. Open the Add-In Manager from the Tools menu. (If the Add-In Manager is already open, close and open it again.)

  4. If the new add-in is displayed in the Add-In Manager list of add-ins, you have successfully registered the add-in.

  5. If the add-in was not displayed in the Add-In Manager, continue with the following steps:
    • Invoke Regedit and find the following key: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\6.0\Addins.

    • Create a new subkey (select the Addins node and then New and Key from the Edit menu) using the propID as its name.

    Note If you've registered add-ins in Visual Basic before, this name is the same as the one you've entered in the vbaddin.ini file.

    • Select the new key, right-click the right pane of Regedit, and select New on the context menu. Select String, enter Friendlyname and press RETURN. The new named value is selected; press RETURN again and enter the name of the add-in as you want it displayed in the Add-In Manager. Select New and String again, but this time enter Description. Use the same procedure for the name to enter a description of the add-in. Select String, New, and enter LoadBehavior. Use 0 for this value. Finally, select New and Integer, and enter LoadBehavior.

    • Exit Regedit and open the Add-In Manager to see the name and description of your new add-in. (If the Add-In Manager is already open, close it and open it again.)


Using Add-In Manager

Use Add-In Manager to select an add-in, load or unload it, and set the add-in's load behavior. You must first register an add-in before it is displayed in the Add-In Manager.

Loading or unloading an add-in

  1. Open Add-In Manager from the Tools menu.

  2. Select your add-in in the listbox. (Double-clicking toggles the Load/Unload setting).

  3. Select the Loaded/Unloaded option in the Load Behavior frame.

Setting an add-in's load behavior

  1. Open Add-In Manager.

  2. Select your add-in in the listbox.

  3. Select one of the following two options in the Load Behavior frame:
    • Choose Load on Startup to load the add-in automatically whenever the development environment is started from the desktop.

    • Choose Command Line to load the add-in whenever the environment is started from the DOS prompt or from a script.


Adding Wizards to the Environment

A Wizard is an ActiveX DLL or Exe that leads a user through a task, often an especially complex or tricky one. Although they can be constructed any way you like, Microsoft implements its wizards in a specific manner.

To add wizards to the Visual Studio environment, there are three main steps you perform:

  • You must create a .vsz file for the wizard and place it in the appropriate directory. For Visual J++, place your file in any subdirectory of \program files\microsoft visual studio\vj98\vbprojectitems\. For Visual Interdev, place your .vsz files in \program files\microsoft visual studio\vj98\templates\.

  • You can optionally create or modify an existing .vsdir file to include information about the wizard. Vsdir files provide additional information on how an item should be displayed in the Add Item or New Project dialog box. A directory containing project items can have multiple .vsdir files. The system processes all .vsdir files when it determines how to display items in the dialogs.

Note If you do not include information about your wizard in a .vsdir file, the wizard will still appear in the dialog box, but it will be placed at the bottom of the available screen space.

  • You must implement the IDT_Wizard interface and its Execute method in your code.


Invoking a Wizard

The environment invokes wizards using a set of parameters you provide in code. Depending on whether the wizard is a AddItem wizard or a NewProject wizard, these parameters may differ slightly.

For each wizard the environment invokes, it calls the IDTWizard::Execute method and pass it the following information:

  • The DTE object, which is the root of the Add-in model.

  • The hWnd to the parent for the wizard dialog.

  • Applicable context parameters for the type of wizard you are invoking. These differ based on whether the wizard is launched from the Add Item or New Project dialog box.

  • Any custom parameters you specify in the .vsz file.

The Execute method returns that the wizard succeeded, failed, or that the user cancelled.

For More Information See "IDTWizard Interface" in the Object Model Reference section of the Environment Extensibility book of the Visual Studio documentation, available on your Miscrosoft Developer Network (MSDN™) Library CD.


Creating VSDIR Files

You can optionally create a .vsdir file for your wizard, or modify an existing file to contain information about the wizard. A .vsdir file is a text file that is used to provide information to the Add Item dialog and the New Project dialog boxes. The .vsdir provides information about the items these dialog boxes display, such as the sort order and the icon to display for each item.

You can have multiple .vsdir files in a single directory; however, one .vsdir file is generally used to contain information for multiple wizards, folders, or templates. An example of a typical .vsdir file is shown below:

Form.java|{AECC23E0-8AA3-11d0-B606-00A0C922E851}|#36201|10|#36202|{AECC23E0-8AA3-11d0-B606-00A0C922E851}|#253|0|Form

Control.java|{AECC23E0-8AA3-11d0-B606-00A0C922E851}|#36203|20|#36204|{AECC23E0-8AA3-11d0-B606-00A0C922E851}|#258|0|Control

DATAFORM.VSZ|{AECC23E0-8AA3-11d0-B606-00A0C922E851}|#36220|40|#36221|{AECC23E0-8AA3-11d0-B606-00A0C922E851}|#262|0|DataForm

Form|{AECC23E0-8AA3-11d0-B606-00A0C922E851}|#36056|10
Class|{AECC23E0-8AA3-11d0-B606-00A0C922E851}|#36054|20

.vsdir files contain a single record per file or folder template, with fields separated by a pipe ( | ) character. Any non-required field for which there is no meaningful data should contain a zero ( 0 ) as a placeholder. The following fields can be specified for a given record:

Field | Meaning
RelPathName | Name of the .vsz file for the wizard.
{clsidPackage} | Optional GUID representing a product (for example, Visual J++) that has a DLL containing localized resources.
LocalizedName | Optional name of the wizard as it will appear in the Add Item dialog — can be a string or a resource identifier of the form: "#ResID."
SortPriority | An integer representing the relative priority of the wizard, with 1 being highest. Determines the sort order of items.
Description | Localizable description of the template or wizard as it will appear in the Add Item dialog box — can be a string or a resource identifier of the form: "#ResID."
DLLPath or {clsidPackage} | Used to load an icon for the wizard from a .dll or .exe file. Specify either the full path to the .dll or .exe, or a GUID of a product that has a .dll file containing localized resources.
IconResourceId | Optional resource identifier within the .dll file that determines the icon to display. If no icon is defined, the shell substitutes the default icon for a file with the same extension as the item.
Flags | A group of flags that disable or enable the Name and Location fields on the Add Item dialog box. The flags can have the following values: Space (" "): enable file name 8192: disable file name
SuggestedBaseName | The default name for the wizard — either a string or a resource identifier of the form: "#ResID." If necessary, the shell appends the base value with an integer to make the name unique. For example, the shell might change MyFile.asp to MyFile1.asp. This default name is shown in the name field in the dialog.


Creating VSZ Files

A .vsz file represents items that appear in the Add Item dialog and the New Project dialog as new items and projects that can be added to your solution. The .vsz file contains information that identifies a wizard and provides custom information for it. The custom information allows you to invoke the same wizard with different data from different .vsz files. This allows a single wizard to perform seemingly different functions.

The following shows the format of a typical .vsz file:

   VSVersion=6.0
   ClassName=MyProgID.Info
   Param=c:\users\fizzle.java
   Param="another custom parameter"

Part | Meaning
VSVersion | Identifies the wizard interface the wizard will be expected to implement.
Classname | The ProgID of the wizard.
Param | Custom parameters that get passed to the wizard upon execution. You can have any number of custom parameters. Each parameter is contained on a separate line. The quotes shown in the example above are optional.

For More Information For information on how to control the way in which .vsz files are displayed, see "Creating VSDIR Files" .


Addin Object, Addins Collection

The Add-in object provides information about an add-in to other Add-in objects.

The Add-ins collection contains one or more Add-in objects.

Remarks

The Add-ins collection is accessed from the DTE object. Every add-in listed in the Add-in Manager Dialog is represented in the Add-ins collection.


BuildEvents Object

Provides events for solution builds.


CommandBarEvents Object

The CommandBarEvents object triggers an event when a control on the command bar is clicked.

Remarks

The CommandBarEvents object is returned by the CommandBarEvents property of the Events object. The object returned has one event in its interface, the Click event.


CommandEvents Object

Provides command events for add-ins.

Remarks

The CommandEvents object is returned by the CommandEvents property of the Event object.


Commands Object

Represents commands in the environment.


Configuration Object, Configurations Collection

The Configuration object represents the solution's build properties. Individual projects may have more specific properties or overrides.

The Configurations collection contains one or more Configuration objects.


DTE Object

The DTE object is the root object from which all other objects and collections in environment extensibility are accessed. DTE stands for Design Time Environment.

Remarks

Add-ins get the DTE object when the environment connects to the add-in in the OnConnection method. There is no other way to access the DTE object.


Events Object

Allows access to all events in the extensibility model. Events are also exposed from specific objects within the extensibility model.

Remarks

The extensibility model contains a root Events object from which add-ins can reference objects supporting general, core extensibility events; for example, DTE.Events.SolutionEvents() and the AddProject event. From the root Events object add-ins can also reference objects supporting product-specific events, such as DTE.Events.VJProjectItemsEvents() and the ItemAdded event. The environment will resolve the name VJDesignerEvents in the registry to dynamically find a typelib describing the object supporting events.


LinkedWindows Collection

Returns the collection of all linked windows contained in a LinkedWindowFrame.

Remarks

Only windows of type LinkedWindowFrame have a LinkedWindows collection. For other window types this collection is empty.

LinkedWindowFrames exist around all windows that can be linked or docked. In general, if all the windows from one LinkedWindowFrame are moved to another, then the LinkedWindowFrame containing no windows is destroyed.

The main window is a special case of a LinkedWindowFrame. If the LinkedWindowFrames that the windows were removed from was the main window, it is not destroyed.


IDTExtensibility2 Interface

To define an addin, you must implement IDT_Extensibility2, which is a dual interface object.

The IDTExtensibility2 interface contains methods that the development environment calls when it connects to the addin, whether through the Add-In Manager, or elsewise. IDT_Extensibility2’s methods appear on the Methods list in this topic.


IDTWizard Interface

To include a wizard in the Add Item or New Project dialog box, you must implement the IDTWizard interface and create a .vsz file in the appropriate directory for the product:

  • For Visual J++, place your .vsz files in any subdirectory of c:\program files\microsoft visual studio\vj98\vjprojectitems\.

  • For Visual Interdev, place your .vsz files in c:\program files\microsoft visual studio\vj98\templates.

The IDT_Wizard interface contains an Execute method that the development environment calls when it connects to the wizard, whether through the Add Item or New Project dialog box.


Project Object, Projects Collection

The Project object is a generic object provided by the extensibility model.

The Projects collection is a generic object used to represent groups of projects, such as Visual J++ projects.

Remarks

The Projects Collection and Project object are extended and implemented by any package providing its own projects. For example, the Visual J++ package defines a VJProjects collection that is immediately accessible from the DTE object, and this collection contains a project object for each Visual J++ project in the solution.

There is no projects collection containing all projects in the solution. The Solution object contains all the projects in the solution.


ProjectItem Object, ProjectItems Collection

The ProjectItem object is a generic object representing an item contained in a project.

The ProjectItems collection is a generic object representing all items in the current instance of the development environment.


Property Object, Properties Collection

The Property object is a generic object representing a property of another object. It provides a way to associate a property with an object other than accessing it from the object as in object1.property1.

The Properties collection is a generic object containing all currently available Property objects.

Remarks

Use the Value property of the Property object to get or set the Variant value of the Property object. Whenever the Value property returns a value of type Object, the Property object's value is a Properties collection. In this way, one Properties collection can be nested within other Properties collections.

If the Property object represents a value that is an object with properties and methods, then get and set the value of the Property object using the Property object's Object property.

If the Property object represents a value that is actually a list of Variant values, then the NumIndices property indicates how many values there are, and the IndexValue property returns each value.


SelectedItem Object, SelectedItems Collection

The SelectedItem object represents a selected project or project item.

The SelectedItems collection returns a collection of all SelectedItem objects.

Remarks

The SelectedItem object allows you to get the project with the focus in order to provide context for an add-in.

A project always has a SelectedItems collection, even when there are no project items selected. For example, if the Project Explorer has focus and a project node is selected, there is one SelectedItem object. That selected item’s Project property points to the selected project, and the ProjectItem property is Null.


SelectionContainer Object

Represents the selection context with objects that model the selection below the project item level. For example if a designer was open for a given project item, then this collection would hold any objects representing selected controls or other items in the environment.

Remarks

The SelectionContainer object is a generic selection tracking object. There is one global selection context for the environment, DTE.SelectedItems.SelectionContainer. Because an item can include any type of object within its context, the SelectionContainer object can represent any type of selected object.


SelectionEvents Object

The SelectionEvents object provides events for changes to a selection.


Solution Object

The Solution object is a collection of all the projects in the environment, and contains many properties of the solution.

Remarks

The Solution object is returned by the Solution property.


SolutionEvents Object

The SolutionEvents object provides events for changes to a solution.

Remarks

The SolutionEvents object is returned by the SolutionEvents property of the DTE object.


TaskList Object

The TaskList object represents the Task List.

Remarks

To obtain the TaskList object, use the following code:

DTE.Windows.Item(vsext_wk_TaskList).Object


TextBuffer Object

The TextBuffer object provides access to the code associated with a project item.

Remarks

Use the TextBuffer object to modify (add, delete, or edit) the code associated with a project item. To access a TextBuffer object, use the DocumentData property of an editor window.

A line is a contiguous sequence of characters that begins immediately following the beginning of the text buffer or following a newline character, and ends at a newline character or the end of the text buffer. All references to lines are to physical lines, not logical lines. For example in a code language that is line-oriented and has line continuation characters, if a line of code is continued to the next line there are two lines, not one.


Window Object, Windows Collection

The Window object represents a window in the development environment.

The Windows collection contains all open or permanent windows in the development environment.


ActiveConfiguration Property

Returns a configuration object representing the configuration in effect for the next build.

Syntax

Property Get ActiveConfiguration () As Configuration


ActiveWindow Property

Returns the current active window.

Syntax

Property Get ActiveWindow () As Window


AddIns Property

Returns the Addins collection, containing all currently available add-ins.

Syntax

Property Get AddIns () As AddIns


AutoListMembers Property

Sets or returns a Boolean value determining whether an available members list automatically pops up when the user types a period following a variable reference.

Syntax

Property Get AutoListMembers ()

Property Let AutoListMembers (Boolean)

The syntax has these parts:

Part | Description
Boolean | Optional Boolean. True means an available members list pops up. False means it will not pop up.


AutoListParams Property

Sets or returns a Boolean value determining whether an argument list automatically pops up when the user types an open parenthesis character ( ‘(‘ ) following a function name.

Syntax

Property Get AutoListParams ()

Property Let AutoListParams (Boolean)

The syntax has these parts:

Part | Description
Boolean | Optional Boolean. True means an argument list pops up. False means it will not pop up.


AutoReloadExternallyModifiedFiles Property

Sets or returns a Boolean value controlling whether the IDE automatically reloads open files if it detects that they have changed on disk outside the IDE.

Syntax

Property Get AutoReloadExternallyModifiedFiles () As Boolean

Property Let AutoReloadExternallyModifiedFiles (Boolean)

The syntax has these parts:

Part | Description
Boolean | Required Boolean value specifying the behavior for reloading files.


BuildEvents Property

Returns the object that sources solution build events.

Syntax

Property Get BuildEvents() As BuildEvents


Caption Property

Returns the string displayed in the window's title bar.

Syntax

Property Get Caption () As String


CaretAtBeginningOfPaste Property

Sets or returns a Boolean determining whether after you paste text, the editor's insertion point is left at the beginning or end of the pasted text.

Syntax

Property Get CaretAtBeginningOfPaste ()

Property Let CaretAtBeginningOfPaste (boolean)

The syntax has these parts:

Part | Description
boolean | A required Boolean value specifying insertion point location after pasting text.


ClickWaitTime Property

Sets or returns a Long indicating the amount of time the user needs to hold down the mouse when clicking in the editor window while the editor does not have focus to cause the editor to regain focus and move the insertion point to the location clicked inside the editor window.

Syntax

Property Get ClickWaitTime ()

Property Let ClickWaitTime (waittime)

The syntax has these parts:

Part | Description
waittime | A required Long expression specifying the delay before the insertion point is moved.


Collection Property

Returns the collection containing the object supporting this property.

Syntax

Property Get Collection () As object

The syntax has these parts:

Part | Description
object | An object in the Applies To list.

Remarks

In the case of the Project object, the Collection property returns one of the "projects" collections accessible directly from the DTE object, for example DTE.VJProjects, DTE.VIProjects, or DTE.UtilityProjects.


CommandBarEvents Property

Returns an object providing events fired when the supplied CommandBarControl object is clicked.

Syntax

Property Get CommandBarEvents(ByVal Control As CommandBarControl) As CommandBarEvents

This syntax has these parts:

Part | Description
Control | The control which causes the event to fire.

Remarks

The CommandBarEvents property is used by an add-in to connect an event with a click of a CommandBarControl object, or to connect to the Click event of any member of the CommandBarControls collection.

The add-in must set the OnAction property to some string value. It can set this value after the CommandBarEvents property is called, and can reset it to a blank string which disconnects the event. If an add-in creates a control and fails to set the OnAction property to some valid string value, then no event is raised on the event object returned by the CommandBarEvents property.


CommandBars Property

Returns a reference to the development environment's CommandBars object.

Syntax

Property Get CommandBars() As CommandBars


CommandEvent Property

Returns the CommandEvents object for the specified command.

Syntax

Property Get CommandEvents(GUID As String, id As Long)As CommandEvent

The property has these parts:

Part | Description
GUID | A required String specifying the GUID for the command group. If the GUID is Null, then this method returns a CommandEvents object representing all commands in the environment.
id | A required Long specifying an index into the command group for the particular command. If the index is Null, then this method returns a CommandEvents object representing all commands in the group.


CommandLineArguments Property

Returns a string representing the command-line arguments.

Syntax

Property Get CommandLineArguments() As String


Commands Property

Returns the Commands object.

Syntax

Property Get Commands () As Commands


Configurations Property

Returns the object representing the build configurations for the solution.

Syntax

Property Get Configurations () As Configurations


Connected Property

Sets or returns a Boolean value indicating whether the addin is loaded and connected.

Syntax

Property Get Connected() As Boolean

Property Let Connected(Boolean)


Count Property

Returns an Integer value indicating the count of objects in the collection.

Syntax

Property Get Count () As Long


CountOfLines Property

Returns a Long value indicating the number of newline sequences in the buffer, plus one if the last newline sequence is not immediately followed by an EOF marker.

Syntax

Property Get CountOfLines () As Long


DefaultCommentToken Property

Returns a string representing the comment token that users cannot rename.

Syntax

Property Get DefaultCommentToken () As String

Remarks

This comment token is useful in situations when an add-in appends code to a project, because the add-in can insert "TODO:" comments to alert the programmer that the newly-inserted code must be edited. The fixed comment token string is localized.


Description Property

Sets or returns a String containing the object's description.

Syntax

Property Get Description () As String

Property Let Description (String)


DisplayMode Property

Sets or returns an enumerated string indicating whether the project is displayed in SDI or MDI mode.

Syntax

Property Get DisplayMode () As DisplayModeEnum

Property Let DisplayMode (DisplayModeEnum)


DocumentData Property

Returns an OLE automation object that models the data in the document. For example, for an editor window, this property with no argument would return a TextBuffer object.

Syntax

Property Get DocumentData([which As String]) As Object

This syntax has these parts:

Part | Description
which | An optional String indicating the window displaying the data.


DocumentOutline Property

Sets or returns a Boolean value determining whether the document outline tool window is shown when attached to editor windows.

Syntax

Property Get DocumentOutline() As Boolean

Property Let DocumentOutline(Boolean)

This syntax has these parts:

Part | Description
Boolean | A Boolean value indicating whether the outline is shown. The outline is shown when showoutline is True, not shown when it is False.

Remarks

If the document outline is a separate window, then the DocumentOutline property is irrelevant.


DragNDropTextEditing Property

Sets or returns a Boolean value determining whether the editor supports drag and drop text editing.

Syntax

Property Get DragNDropTextEditing () As Boolean

Property Let DragNDropTextEditing (Boolean)

This syntax has these parts:

Part | Description
Boolean | A Boolean value indicating whether drag and drop text editing is supported. True means yes, False means no.

Remarks

Text editors often allow you to select a region and then left click and drag the region to a new location in the document. That performs a cut and paste operation. You may also be able to CTRL-LeftClick text, and drag it to a new location, performing a copy and paste operation. The DragNDropTextEditing property setting indicates whether the Visual Studio editor allows drag and drop text editing.


DTE Property

Returns the top-level extensibility object.

Syntax

Property Get DTE () As DTE


EnableLeftClickForURLs Property

Sets or returns a Boolean value determining whether the editor underlines URLs, and enables a single left click for jumping to the URL using the system-registered web browser.

Syntax

Property Get EnableLeftClickForURLs ()

Property Let EnableLeftClickForURLs (Boolean)

The syntax has these parts:

Part | Description
Boolean | Optional Boolean. True means URLs are active as described above. False means they are not.


Events Property

Returns a reference to the Events object.

Syntax

Property Get Events () As Events


FileCount Property

Returns the number of files associated with the project item. Project items can be stored across one or multiple files, as in .frm and .frx files.

Syntax

Property Get File FileCount () As Integer


FileName Property (DTE Object)

Returns the name of an ASCII file containing all the keyboard bindings in effect. When setting, the environment reads the file and installs the specified bindings.

Syntax

Property Get FileName() As String


FileName Property (DTE Properties Collection)

Sets or returns the name of the keyboard mapping scheme chosen in the Options command on the Tools menu.

Syntax

Property Get FileName(String)

Property Let FileName(String)

This syntax has these parts:

Part | Description
String | A required String indicating the name of the file containing the keyboard mapping scheme.

Remarks

If no keyboard mapping scheme is chosen, this property returns an empty string.

If you supply the name of a file that was previously saved as a keyboard scheme in the Options dialog (accessed from the Tools menu), then the environment reads the file and applies the keybindings it contains.


FileName Property (Project Object)

Sets or returns a full pathname indicating the location of the project file.

Syntax

Property Get FileName () As String

Property Let FileName(fname As String)

This syntax has these parts:

Part | Description
fname | A String expression indicating the project file's pathname.


FileName Property (Solution Object)

Returns the full pathname of the solution file, containing information about the projects in the solution, settings, and so on.

Syntax

Property Get FileName() As String


FileNames Property

Returns the full pathnames of the files associated with a project item.

Syntax

Property Get FileNames(index As Integer) As String

This syntax has these parts:

Part | Description
index | Required Integer indicating the particular file associated with the project item.


FontCharacterSet Property (Environment)

Returns an enumerated type indicating the character set used to display text in the editor.

Syntax

Property Get FontCharacterSet()

This syntax has these parts:

Part | Description
TextEditorFontCharSet | Required String expression indicating an alphabet. See the table in Remarks for values.

Remarks

The default for this property is determined by the system.

Element | Value
EDITOR_ANSI_CHARSET | 0
EDITOR_DEFAULT_CHARSET | 1
EDITOR_SYMBOL_CHARSET | 2
EDITOR_SHIFTJIS_CHARSET | 128
EDITOR_HANGEUL_CHARSET | 129
EDITOR_GB2312_CHARSET | 134
EDITOR_CHINESEBIG5_CHARSET | 136
EDITOR_OEM_CHARSET | 255
EDITOR_JOHAB_CHARSET | 130
EDITOR_HEBREW_CHARSET | 177
EDITOR_ARABIC_CHARSET | 178
EDITOR_GREEK_CHARSET | 161
EDITOR_TURKISH_CHARSET | 162
EDITOR_VIETNAMESE_CHARSET | 163
EDITOR_THAI_CHARSET | 222
EDITOR_EASTEUROPE_CHARSET | 238
EDITOR_RUSSIAN_CHARSET | 204
EDITOR_MAC_CHARSET | 77
EDITOR_BALTIC_CHARSET | 186


FontCharacterSet Property (Text Editor)

Sets or returns an enumerated type determining the character set used to display text in the editor.

Syntax

Property Get FontCharacterSet()

Property Let FontCharacterSet(TextEditorFontCharSet)

This syntax has these parts:

Part | Description
TextEditorFontCharSet | Required String expression indicating an alphabet. See the table in Remarks for values.

Remarks

The default for this property is determined by the system.

Element | Value
EDITOR_ANSI_CHARSET | 0
EDITOR_DEFAULT_CHARSET | 1
EDITOR_SYMBOL_CHARSET | 2
EDITOR_SHIFTJIS_CHARSET | 128
EDITOR_HANGEUL_CHARSET | 129
EDITOR_GB2312_CHARSET | 134
EDITOR_CHINESEBIG5_CHARSET | 136
EDITOR_OEM_CHARSET | 255
EDITOR_JOHAB_CHARSET | 130
EDITOR_HEBREW_CHARSET | 177
EDITOR_ARABIC_CHARSET | 178
EDITOR_GREEK_CHARSET | 161
EDITOR_TURKISH_CHARSET | 162
EDITOR_VIETNAMESE_CHARSET | 163
EDITOR_THAI_CHARSET | 222
EDITOR_EASTEUROPE_CHARSET | 238
EDITOR_RUSSIAN_CHARSET | 204
EDITOR_MAC_CHARSET | 77
EDITOR_BALTIC_CHARSET | 186


FontFamily Property (Environment)

Returns a String expression indicating the face used to display text in the editor.

Syntax

Property Get FontFamily() As String

This syntax has these parts:

Part | Description
String | Required String expression indicating the font name, for example, “Courier New”.

Remarks

The default for this property is determined by the system.


FontFamily Property (Text Editor)

Sets or returns a String expression determining the face used to display text in the editor.

Syntax

Property Get FontFamily() As String

Property Let FontFamily(String)

This syntax has these parts:

Part | Description
String | Required String expression indicating the font name, for example, “Courier New”.

Remarks

The default for this property is determined by the system.


FontSize Property (Environment)

Returns the size of the font used to display text in the editor.

Syntax

Property Get FontSize() As Short

This syntax has these parts:

Part | Description
Short | Required Short value indicating the font size in points.

Remarks

The default for this property is determined by the system.


FontSize Property (Text Editor)

Returns or sets the size of the font used to display text in the editor.

Syntax

Property Get FontSize() As Short

Property Let FontSize(Short)

This syntax has these parts:

Part | Description
Short | Required Short value indicating the font size in points.

Remarks

The default for this property is determined by the system.


GoToAnchorAfterEscape Property

Sets or returns a Boolean value determining whether the insertion point is placed at the beginning or end of a selection following an Escape keystroke while there is a selection.

Syntax

Property Get GoToAnchorAfterEscape () As Boolean

Property Let GoToAnchorAfterEscape (Boolean)

This syntax has these parts:

Part | Description
Boolean | Boolean value determining insertion point placement. True means it is placed at the point where the action that created the selection was begun. False means it is placed at the other end.


GUID Property

Returns the addin’s CLSID as obtained from the addin's registry entry.

Syntax

Property Get GUID () As String


Height, Width Properties

Sets or returns a Single value indicating the dimensions of the window in pixels.

Syntax

Property Get Height() As Single

Property Get Width() As Single

Property Let Height(ByVal value As Single)

Property Let Width(ByVal value As Single)

This syntax has these parts:

Part | Description
value | Optional Single indicating window height or width.


HorizontalScrollbar Property

Sets or returns a Boolean value determining whether editor windows have a horizontal scrollbar.

Syntax

Property Get HorizontalScrollBar() As Boolean

Property Let HorizontalScrollBar (Boolean)

This syntax has these parts:

Part | Description
Boolean | Optional Boolean value. True means a scrollbar is present in editor windows, False means it is absent.


IndentSize Property

Sets or returns a Long value indicating the width of an indent level in spaces.

Syntax

Property Get IndentSize () As Long

Property Let IndentSize (Long)

This syntax has these parts:

Part | Description
Long | Optional Long value. Setting a value outside of the range 1-60 inclusive fails silently.


IndentStyle Property

Sets or returns an enumerated type determining the behavior caused by a return keystroke in the editor.

Syntax

Property Get IndentStyle () As IndentStyle

Property Let IndentStyle (IndentStyle)

The syntax has these parts:

Part | Description
IndentStyle | Required. An enumerated type specifying the desired behavior. Values include INDENT_NONE, INDENT_DEFAULT (block), and INDENT_SMART.


IndexedValue Property

Sets or returns one element of a list.

Syntax

Property Get IndexedValue (index1 As Variant, Optional index2 As Variant, Optional index3 As Variant, Optional index4 As Variant) As VariantSettings

Property Let IndexedValue (index1 As Variant, Optional index2 As Variant, Optional index3 As Variant, Optional index4 As Variant) As VariantSettings

This syntax has these parts:

Part | Description
index1 | Required, the element to return.
index2 - 4 | Optional, the element to return. Reserved for future use.

Remarks

Ignored unless the property returns a list as indicated by the NumIndices property.


Info Property

Returns a string providing information on the selected item.

Syntax

Property Get Info(i) As String

This syntax has these parts:

Part | Description
i | Required, an integer identifying the string associated with the item.

Remarks

Multiple strings can be stored for an item. For example, a single project item may have more than one file associated with it.


InfoCount Property

Returns an integer indicating the number of strings included in the Info property.

Syntax

Property Get InfoCount As Integer


InsertTabs Property

Sets or returns a Boolean value determining whether tabs in the editor use spaces or tab characters.

Syntax

Property Get InsertTabs()

Property Let InsertTabs(boolean)

This syntax has these parts:

Part | Description
boolean | A required Boolean value. True means tabs are used when inserting indentation automatically. False means spaces are used.


IsDebug Property

Sets or returns whether the configuration is for debug or release.

Syntax

Property Get IsDebug () As Boolean

Property Let IsDebug (Debug As Boolean) As Boolean

This syntax has these parts:

Part | Description
Debug | Set to True for debug, False for release.


IsDirty Property

Returns a Boolean value indicating whether or not the object was changed since the last time it was saved.

Syntax

Property Get IsDirty () As Boolean


IsOpen Property

Returns a Boolean value indicating whether the ProjectItem is open for a particular view (designer, editor, and so on).

Syntax

Property Get IsOpen (viewkind As String) As Boolean

This syntax has these parts:

Part | Description
viewkind | Required, a GUID string specifying the kind of view to open. The ProjectItems collection supports at least the following views: CodeView, DesignerView, and PrimaryView.


Kind Property

Returns a GUID String indicating the kind or type of the object. The GUID String should be available in the type library for the code contributing the object to the extensibility model, or in the documentation.

Syntax

Property Get Kind () As String


Left, Top Properties

Left returns or sets the distance in pixels between the internal left edge of an object and the left edge of its container.

Top returns or sets the distance in pixels between the internal top edge of an object and the top edge of its container.

Syntax

Property Get Left() As Single

Property Get Top() As Single

Property Let Left(ByVal Single As Single)

Property Let Top(ByVal Single As Single)

This syntax has these parts:

Part | Description
Single | An optional Single value.


Lines Property

Returns the specified block of lines.

Syntax

Property Get Lines(startLine As Long, count As Long) As String

This syntax has these parts:

Part | Description
startLine | Required Long indicating the first line in the returned block.
count | Required Long indicating the number of lines in the returned block.


LinkedWindowFrame Property

Returns the Window object representing the window frame containing the window. If the window is not linked, or is of type LinkedWindowFrame, then the LinkedWindowFrame property returns Nothing.

Syntax

Property Get LinkedWindowFrame () As Window


LinkedWindows Property

Returns a LinkedWindows collection.

Syntax

Property Get LinkedWindows () As LinkedWindows

Remarks

Only windows of type LinkedWindowFrame have a LinkedWindows collection. For other window types this collection is Nothing.


LocaleID Property

Returns the ID of the locale in which the environment is running.

Syntax

Property Get LocaleID () As Long

Remarks

The ID returned by the LocaleID property indicates a folder storing localized resource DLLs supporting various add-ins.


MainWindow Property

Returns a Window object representing the main environment window. This object is of type MainWindow, but has a LinkedWindows collection containing all of the docked windows.

Syntax

Property Get MainWindow () As Window

Remarks

The LinkedWindows collection is the collection of windows docked to the sides of the main environment window. If two windows are docked together but not attached in any way to the MainWindow, they do not appear in this collection.


MarginIndicatorBar Property

Returns or sets a Boolean value indicating whether a Margin Indicator Bar is displayed in the editor.

Syntax

Property Get MarginIndicatorBar () As Boolean

Property Let MarginIndicatorBar (Boolean)

This syntax has these parts:

Part | Description
Boolean | An optional Boolean value. True means the Margin Indicator Bar is opened, False means it is closed.


MiscFilesProjectSavesLastNItems Property

Sets or returns a Short value indicating the number of files stored in the Miscellaneous Files Project.

Syntax

Property Get MiscFilesProjectSavesLastNItems () As Short

Property Let MiscFilesProjectSavesLastNItems (Short)

This syntax has these parts:

Part | Description
Short | An optional Short value.


MRUListContainsNItems Property

Sets or returns a Short value indicating the number of files stored in the most recently used submenu.

Syntax

Property Get MRUListContainsNItems () As Short

Property Let MRUListContainsNItems (Short)

This syntax has these parts:

Part | Description
Short | An optional Short value.


MultiSelect Property

Returns a Boolean value indicating whether the selection includes multiple items.

Syntax

Property Get MultiSelect () as Boolean

Remarks

True means multiple items are included, False means a single item is included.


Name Property

Sets or returns the name of the object.

Syntax

Property Get Name () As String

Remarks

For the AddIn object the Name property is initially obtained from the display name of the add-in as it is registered. This value can only be changed by the add-in itself during the OnConnection event. At other times it is read-only.


Name Property (ProjectItem, Project Objects)

Sets or returns the name of the project.

Syntax

Property Get Name () As String

Property Let Name() As String

Remarks

This is the display name of the object, for example the name appearing in the Project Explorer as the label of a node in the Treeview control.


NumIndices Property

Returns a Long value representing the number of items in the list value.

Syntax

Property Get NumIndices () As Long

Remarks

The valid arguments to the IndexedValue property are 1 through the return value from the NumIndices property, inclusive.


Object Property (AddIn Object)

Sets or returns an additional OLE automation object for support of other add-ins.

Syntax

Property Get Object() As Object

Property Let Object(Object)

Remarks

The OnConnection method can be used to set this property.


Object Property (Property Object)

Sets or returns the value of the Property object when the type of the value is Object.

Syntax

Property Get Object() As Object

Property Let Object(Data As Object)

This syntax has these parts:

Part | Description
Data | An object to which the Property object is set.

Remarks

If the add-in uses Property.Value instead of Property.Object, then the Property object returns a Properties collection instead of the Object value.


Object Property (Window Object)

Returns the extensibility object for the tool represented by the window.

Syntax

Property Get Object() as Object


ObjectKind Property

Returns the type of the Window.Object object, a GUID string representing the tool contained in the window.

Syntax

Property Get ObjectKind() as String


OnRunOrPreview Property

Sets or returns an enumerated value determining whether the environment should save everything before running or previewing the solution.

Syntax

Property Get OnRunOrPreview() As OnBuildRunEnum

Property Let OnRunOrPreview(OnBuildRunEnum)

This syntax has these parts:

Part | Description
OnBuildRunEnum | Optional enumerated value. SAVE_CHANGES indicates a save should occur before run or preview. CONFIRM_SAVE indicates a check should be done to see whether anything needs to be saved, and notify the user if so. NO_SAVE indicates neither a check nor save will be done.


OnStartup Property

Sets or returns a value indicating Visual Studio’s startup behavior.

Syntax

Property Get OnStartup()

Property Let OnStartup(OnStartupEnum)

This syntax has these parts:

Part | Description
OnStartupEnum | One of the following values: EMPTY_ENVIRONMENT, NEW_SOLUTION_DIALOG, LOAD_LAST_SOLUTION.


Parent Property

Returns the parent object.

Syntax

Property Get Parent () As Object


ProgID Property

Returns the ProgID as obtained from the add-in's registry entry.

Syntax

Property Get ProgID () As String


Project Property

Returns the Project object associated with the object the Project property was invoked on.

Syntax

Property Get Project() As Project


ProjectItem Property (SelectedItem Object)

Returns the ProjectItem object.

Syntax

Property Get ProjectItem () As String


ProjectItem Property (Window Object)

Returns the ProjectItem object associated with the window.

Syntax

Property Get ProjectItem () As ProjectItem


ProjectItems Property

Returns a ProjectItems collection for the object.

Syntax

Property Get ProjectItems () As ProjectItems

Remarks

The ProjectItems property of the ProjectItem object returns a collection of project items that may be hierarchically below the project item. For example, Visual J++ subdirectories.


Properties Property

Returns the Properties collection.

Syntax

Property Get Properties () As Properties


Properties Property (DTE Object)

Returns a collection object representing all the available categories and subcategories of environment-level properties.

Syntax

Property Get Properties (Category As String, [Page As String]) As Properties

This syntax has these parts:

Part | Description
Category | Required String identifying a property category, for example "Keyboard" or "Source Control".
Page | Optional String identifying a properties page within the category identified by Category.

Remarks

If the specified properties collection is not available, this property returns NULL.


ReuseSavedActiveDocWindow Property

Sets or returns a Boolean value controlling whether the current window is used to display a new file if the current document is saved.

Syntax

Property Get ReuseSavedActiveDocWindow As Boolean

Property Let ReuseSavedActiveDocWindow (Boolean)

The syntax has these parts:

Part | Description
Boolean | Optional Boolean. False means always open a new document window for each document opened. True means reuse the current window.


SelectedItems Property

Returns a collection containing the items currently selected in the environment.

Syntax

Property Get SelectedItems () As SelectedItems


SelectionContainer Property

Returns the collection of objects representing the selection context at a finer granularity than Project and ProjectItem. For example, this collection could contain objects representing controls on a design surface or nodes in a document outline for a particular ProjectItem.

Syntax

Property Get SelectionContainer () As SelectionContainer


SelectionEvents Property

Returns the Events object for the selection.

Syntax

Property Get SelectionEvents () As SelectionEvents

Remarks

Whenever something is selected in the development environment, the environment creates a model of the selection. The events provided by the Events object in this case let add-ins know when the SelectedItems collection is updated.


SelectionMargin Property

Sets or returns a Boolean value determining whether there is space at the left of the text pane for special selection operations, drawing breakpoint glyphs, and so on.

Syntax

Property Get SelectionMargin ()

Property Let SelectionMargin (Boolean)

This syntax has these parts:

Part | Description
Boolean | Optional Boolean value. True means the space is present. False means it is not.


ShowStatusBar Property

Sets or returns a Boolean value determining whether the status bar is visible.

Syntax

Property Get ShowStatusBar ()

Property Let ShowStatusBar (boolean)

This syntax has these parts:

Part | Description
boolean | Required Boolean. True means the status bar is visible, False means invisible.


Solution Property

Returns the Solution object, which represents all currently open projects in the current instance of the development environment.

Syntax

Property Get Solution () As Solution


SolutionEvents Property

Returns the Events object for the solution.

Syntax

Property Get SolutionEvents () As SolutionEvents


StreamSelectionMode Property

Sets or returns a Boolean value determining whether dragging the mouse selects in stream mode or block mode.

Syntax

Property Get StreamSelectionMode() As Boolean

Property Let StreamSelectionMode(Boolean)

This syntax has these parts:

Part | Description
Boolean | Optional Boolean. True means the mouse selects in stream mode, False in block mode.


TabSize Property

Sets or returns a Long value determining tab size in the editor.

Syntax

Property Get TabSize () As Long

Property Let TabSize (Long)

This syntax has these parts:

Part | Description
Long | An optional Long value between 1 and 60 inclusive, specifying the tab size.


TemplatePath Property

Returns the full pathname of the directory containing templates in the Visual Studio install directory.

Syntax

Property Get TemplatePath(projectkind As String) As String

This syntax has these parts:

Part | Description
projectkind | A required String value, the GUID identifying the kind of project.


Type Property

Returns an enumerated string indicating the window type.

Syntax

Property Get Type () As vbext_WindowType

Remarks

If the window is for an Environment tool, then the Type property indicates which one. If the window is for a package-supplied tool or document window, the type is vbext_wt_ToolOrDocument, and the ObjectKind property indicates package-specific type information.

Element | Value
vbext_wt_CodeWindow | 0
vbext_wt_Designer | 1
vbext_wt_Browser | 2
vbext_wt_Watch | 3
vbext_wt_Locals | 4
vbext_wt_Immediate | 5
vbext_wt_ProjectWindow | 6
vbext_wt_PropertyWindow | 7
vbext_wt_Find | 8
vbext_wt_FindReplace | 9
vbext_wt_Toolbox | 10
vbext_wt_LinkedWindowFrame | 11
vbext_wt_MainWindow | 12
vbext_wt_Preview | 13
vbext_wt_ColorPalette | 14
vsext_wt_ToolWindow | 15
vsext_wt_Document | 16
vsext_wt_OutputWindow | 17
vsext_wt_TaskList | 18
vsext_wt_Autos | 19
vsext_wt_CallStack | 20
vsext_wt_Threads | 21
vsext_wt_DocumentOutline | 22
vsext_wt_RunningDocuments | 23


UndoCaretAction Property

Sets or returns a Boolean value determining whether the Undo command affects all commands, or only changes to text.

Syntax

Property Get UndoCaretAction ()

Property Let UndoCaretAction (boolean)

The syntax has these parts:

Part | Description
boolean | An optional Boolean value specifying the desired behavior. True means undo all commands including moving the insertion point, creating selections and so on, as well as modifying text. False means only undo commands that modify text.


UniqueName Property

Returns the name of the project as a relative pathname from the directory containing the solution file leading to the project file.

Syntax

Property Get UniqueName () As String

Remarks

The string returned by the UniqueName property can be used as the parameter in the Item method on the Solution object.


Value Property

Sets or returns the value of the property returned by the Property object.

Syntax

Property Get Value () As Variant

Property Let Value (Data As Variant) As Variant

Remarks

The Value property determines the default value for the Property object. Since this returns a Variant, any type of property should be accessible. Objects should be returned as the object type, arrays as arrays. A Property object representing multiple values returns them through the IndexedValue property, and the number of values is returned by the NumIndices property. Setting the Value property works appropriately depending on the type of the value.

The Value property is always of type Variant, and it is possible that some variant values cannot be packaged into remote function calls. If the property type doesn’t marshall, then it is accessible only by in-process consumers of the object model. Moving data and pointers between two memory spaces, whether two processes or two threads in the same process, is called marshalling. Marshalling is really just the process of packing, unpacking, and translating data or pointers from one interface to another.

If the property that the Property object represents is read/write at design time, then the Value property is read/write. If the property is read-only, attempting to set the Value property causes an error. If the property is write-only, attempting to return the Value property causes an error.

If the add-in interacts with the Value property and in doing so causes a critical error, an exception is generated. If the add-in interacts with the Value property and causes a message box to be displayed, the development environment assumes the default for the message box.


Version Property

Returns the host application's version number as a String.

Syntax

Property Get Version () As String


VerticalScrollbar Property

Sets or returns a Boolean value determining whether there is a vertical scrollbar on editor windows.

Syntax

Property Get VerticalScrollBar ()

Property Let VerticalScrollBar (scrollbar)

The syntax has these parts:

Part | Description
scrollbar | Optional Boolean. True means a scrollbar is present. False means it is absent.


VirtualSpace Property

Sets or returns a Boolean value determining whether non-printing characters are displayed in the editor.

Syntax

Property Get VirtualSpace ()

Property Let VirtualSpace (boolean)

The syntax has these parts:

Part | Description
boolean | Optional Boolean. True means nonprinting characters are displayed as unique graphic elements. False means they are displayed as blank space.


Visible Property

Sets or returns a Boolean value determining whether the window is visible.

Syntax

Property Get Visible ()

Property Let Visible (ByVal value As Boolean)

The syntax has these parts:

Part | Description
value | Optional Boolean. True means the window is visible. False means it is not.

Remarks

Docked windows must be undocked before the Visible property can be set to False, or else an error occurs.


WindowMenuContainsNItems Property

Sets or returns a Short value determining the maximum number of document windows that can be listed on the Windows menu.

Syntax

Property Get WindowMenuContainsNItems () As Short

Property Let WindowMenuContainsNItems (Short)

The syntax has these parts:

Part | Description
Short | An optional Short specifying the maximum number of windows.


Windows Property

Returns the Windows collection.

Syntax

Property Get Windows () As Windows


WindowState Property

Sets or returns an enumerated string determining the state of the window.

Syntax

Property Get WindowState() As vbext_WindowState

Property Let WindowState(ByVal thiswindow As vbext_WindowState)

The syntax has these parts:

Part | Description
thiswindow | An optional enumerated string determining window state.

Remarks

Element | Value
vbext_ws_Normal | 0
vbext_ws_Min | 1
vbext_ws_Max | 2


Add Method (Commands Object)

Adds the command, as represented by the GUID and ID, to the Commands object.

Syntax

Sub Add (Guid As String, ID As Long, [Control As CommandBarControl])

This syntax has these parts:

Part | Description
Guid | Required String. The GUID for the command group.
ID | Required Long. The index into the command group for the particular command.
Control | Optional. The CommandBarControl that when clicked by the user causes the command specified by Guid and ID to fire.

Remarks

If Control is supplied, then when the user clicks the control (it must have previously been added to a command bar), an event handler executes the specified command.


Add Method (LinkedWindows Collection)

Adds a window to the collection of currently linked windows.

Syntax

Sub Add (ThisWindow As Window)

This syntax has these parts:

Part | Description
ThisWindow | Required, the window added to the collection.

Remarks

A window that is a member of a LinkedWindowFrame can be added to another LinkedWindowFrame. When this happens, the Add method removes the window from the LinkedWindowFrame that currently contains it. If removing the window leaves the LinkedWindowFrame empty, then the Add method destroys the LinkedWindowFrame.

A LinkedWindowFrame exists around all tool windows except the Object Browser and the Find/Replace windows. LinkedWindowFrames exist around all windows that can be linked or docked.


AddFromDirectory Method

Adds ProjectItem objects and sets ProjectItems properties, recursively for each item in each folder, and returns a newly created ProjectItem object representing the FileName argument to this method.

Syntax

Sub AddFromDirectory (FileName As String) As ProjectItem

This syntax has these parts:

Part | Description
FileName | Required String. A full pathname identifying the initial folder containing items to be added.


AddFromFile Method (AddIns Collection)

Causes the environment to register a specified add-in DLL.

Syntax

Sub AddFromFile (Filename As String) As Add-in

This syntax has these parts:

Part | Description
Filename | Required String. A full pathname specifying the DLL to be registered.


AddFromFile Method (ProjectItems Collection)

Adds a ProjectItem object from a file already installed in the project directory structure.

Syntax

Sub AddFromFile (Filename As String) As ProjectItem

This syntax has these parts:

Part | Description
Filename | Required String. A full pathname indicating the file the project item is associated with.


AddFromFile Method (Solution Object)

Adds a project to the solution based on a project file already installed in the correct location.

Syntax

Sub AddFromFile(Filename As String, [Exclusive As Boolean = False]) As Project

This syntax has these parts:

Part | Description
Filename | Required String. A full pathname pointing to the project file.
Exclusive | Optional Boolean. If True, then the environment closes down the current solution and opens a new solution with project identified by Filename added. If False, then the project identified by Filename is added to the existing solution. The default is False.


AddFromFile Method (TextBuffer Object)

Adds the contents of a file to a TextBuffer object.

Syntax

Sub AddFromFile (fname As String, [StartLine As Long])

This syntax has these parts:

Part | Description
fname | Required String. A full pathname pointing to the file containing the text to be added.
StartLine | Optional Long value specifying the line number, to the beginning of which AddFromFile adds text. The valid range is 1 through the last line number in the current TextBuffer object.

Remarks

The AddFromFile method adds a file’s contents to the end of the text buffer, ignoring whether the text buffer ends in a newline sequence. When StartLine is supplied, the AddFromFile method adds the file’s contents immediately before the first character of the specified line number. If the line number is out of range, then the behavior is as though no StartLine argument was supplied.


AddFromString Method

Adds a string to the TextBuffer object.

Syntax

Sub AddFromString(newcode As String, [StartLine As Long])

This syntax has these parts:

Part | Description
newcode | Required String containing the code to be added.
StartLine | An optional Long value specifying the line number, at the beginning of which the string is added. If StartLine is unspecified, then AddFromString adds the string to the end of the text buffer, ignoring whether the buffer ends in a newline character.


AddFromTemplate Method (ProjectItems Collection)

Copies the indicated file to the ProjectItems directory and then adds the file as a member of the ProjectItems collection.

Syntax

Sub AddFromTemplate (Filename As String, Name As String) As ProjectItem

This syntax has these parts:

Part | Description
Filename | Required String. A full pathname specifying the file to copy to the ProjectItems directory and to add to the ProjectItems collection.
Name | A required String providing a name for the ProjectItem object in the ProjectItems collection. This will also become the name of the item in the destination directory, keeping the same file extension.


AddFromTemplate Method (Solution Object)

Copies a project file to a specified location and adds it to the solution as a project file.

Syntax

Sub AddFromTemplate(FileName As String, Destination As String, Name As String, [Exclusive As Boolean = False]) As Project

This syntax has these parts:

Part | Description
FileName | Required String. A full pathname specifying the template project file.
Destination | A required String providing the path to the directory for the file specified by filename.
Name | A required String providing the display name of the project in the Solution Browser. This is also the name of the project file without the extension. The AddFromTemplate method fails if the new project file name already exists in the destination folder.
Exclusive | Optional Boolean. If True, then the environment closes down the current solution and opens a new solution with this project added. If False, then the project is added to the existing solution. The default is False.


Build Method

Starts a solution build.

Syntax

Sub Build ()

Remarks

The build runs asynchronously, therefore this method call returns immediately. The BuildDone event occurs when the build is finished.


Close Method (Solution Object)

Causes the development environment to close the current solution file.

Syntax

Sub Close (FileName As Boolean)

This syntax has these parts:

Part | Description
FileName | Required String identifying the filename to use when saving the solution.


Close Method (Window Object)

Closes and destroys the window.

Syntax

Sub Close ()

Remarks

For designer windows this destroys the contained designer. For LinkedWindowFrames this destroys the window, and all contained windows become unlinked separate windows. For linked windows this causes an error if the linked window is not removed from all links before being closed. For IDE windows this only works for the Project window, all other IDE windows cause an error if closed.

A LinkedWindowFrame exists around all tool windows except the Object Browser and the Find/Replace windows. LinkedWindowFrames exist around all windows that can be linked or docked.


CreateToolWindow Method

Creates a new tool window containing the indicated ActiveX document.

Syntax

Function CreateToolWindow(AddInInst As AddIn, ProgId As String, Caption As String, GuidPosition As String, DocObj As Object)

This syntax has these parts:

Part | Description
AddInInst | Required add-in object whose lifetime determines the lifetime of the new tool window.
ProgId | Required String. Programmatic ID of the ActiveX document object.
Caption | Required String. Caption for the new tool window.
GuidPosition | Required String. Unique identifier for the new window.
DocObj | Required ActiveX document object, hosted in the new tool window.


DeleteLines Method

Deletes a single line of code or a specified range of lines in a TextBuffer object.

Syntax

Sub DeleteLines(StartLine As Long, [Count As Long = 1])

This syntax has these parts:

Part | Description
StartLine | Required Long value indicating the first line in the range to be deleted.
Count | Optional Long value indicating the number of lines, beginning with the line specified in StartLine , to be deleted. The default is 1.

Remarks

If the number of lines specified in Count is greater than the lines present beginning at StartLine, then this method deletes from StartLine to the end of the buffer.


Execute Method

Called when a wizard is launched from either the Add Item or the New Project dialog box.

Syntax

Sub Execute (ByVal Name as Object, hWnd as Long, ContextParams() as Variant, CustomParams() as Variant)

This syntax has these parts:

Part | Description
Name | A dispatch pointer to the highest level DTE automation object for the Visual Studio environment.
HWnd | The hWnd handle for the parent for the wizard dialog box.
ContextParams() | An array of elements that vary depending on whether your wizard is launched from the Add Items or the New Project dialog box. See Settings, below, for available values.
CustomParams() | An array of user-defined parameters, determined by param= statements in the wizard's .vsz file. Use the parameters passed in this array to customize a single wizard’s behavior to perform multiple tasks.

Settings

The settings for ContextParams are:

Setting | Description
WizardType | A constant indicating the type of wizard. Either: vsext_wzk_AddItem - or - vsext_wzk_NewProject
ProjectName | The Visual Studio project name.
ProjectItems | A pointer to the ProjectItems Collection on which the wizard will operate. This is passed to the wizard based on the project hierarchy selection. Valid for AddItem wizards only.
LocalDirectory | The local location where the wizard's working project files exist.
ItemName | The name of the item that is to be added. This is file name that the user types in (or accepted default) from the Add-Items dialog. Based on the Flags set in the VSDIR file, this may be null. Valid for AddItem wizards only.
Fexclusive | A boolean indicating whether the project should be added to the current solution, or whether the system should close the current solution, create a new one, and then add the project Valid for NewProject wizards only.
InstallationDirectory | The directory path where Visual Studio is installed.


ExpandView Method

Expands views of the project structure to show the ProjectItem. For example, expands the view in the Project Explorer window to show the ProjectItem in the tree control.

Syntax

Sub ExpandView ()


Find Method

Searches a TextBuffer for a specified string.

Syntax

Function Find(Target As String, StartLine As Long, StartColumn As Long, EndLine As Long, EndColumn As Long, [WholeWord As Boolean = False], [MatchCase As Boolean = False], [PatternSearch As Boolean = False]) As Boolean

This syntax has these parts:

Part | Description
Target | Required String containing the text or pattern you want to find.
StartLine | Required Long value specifying the line at which you want to start the search; will be set to the line of the match if one is found. The first line is number 1.
StartColumn | Required Long specifying the column at which you want to start the search; will be set to the column containing the match if one is found. The first column is 1.
EndLine | Required Long specifying the last line of the match if one is found. The last line may be specified as -1.
EndColumn | Required Long specifying the column at which you want to end the search. The last column may be designated as -1.
WholeWord | Optional Boolean value specifying whether to only match whole words. If True, only matches whole words. False is the default.
MatchCase | Optional Boolean value specifying whether to match case. If True, the search is case sensitive. False is the default.
PatternSearch | Optional Boolean value specifying whether or not the target string is a regular expression pattern. If True, the target string is a regular expression pattern. False is the default.

Remarks

Find returns True if a match is found and False if a match isn't found. The MatchCase and PatternSearch arguments are mutually exclusive; if both arguments are passed as True, an error occurs. The content of the Find dialog box isn't affected by the Find method. The specified range of lines and columns is inclusive, so a search can find the pattern on the specified last line if EndColumn is supplied as -1 or the length of the line.


GetObject Method

Returns an interface or object that can be accessed at run time by name. This is most useful in languages that do not support a mechanism like late binding in Visual Basic.

Syntax

Method GetObject(bstrName) As Object

This syntax has these parts:

Part | Description
bstrName | Required String indicating the object. The name must be in the registry under HKEY_LOCAL_MACHINE/Microsoft/Visual Studio/6.0/<package>/Automation/.


Item Method

Returns an indexed member of a collection.

Syntax

Sub Item (ByVal Index As Variant) As Object

This syntax has these parts:

Part | Description
Index | Required Variant indicating by name or position an item in the collection. Tool windows in the Windows collection are indexed with constants representing the GUID string for each tool window.
Object | This is the item returned.


OnAddinsUpdate Method

Called when the add-ins collection changes.

Syntax

Sub OnAddInsUpdate (Custom() As Variant)

This syntax has these parts:

Part | Description
Custom | Reserved for future use.


OnBeginShutdown Method

BeginShutdown Method

Occurs immediately before shutting down the environment.

Syntax

Sub BeginShutdown (Custom() As Variant)

This syntax has these parts:

Part | Description
Custom | Reserved for future use.

Remarks

Add-ins must implement this method.


OnConnection Method

The environment calls this method loading the add-in. It connects the add-in to the extensibility object model.

Syntax

Sub OnConnect (ByVal Application As Object, ByVal Mode As vbext_ConnectMode, ByVal AddinInst As Object, Custom() As Variant)

This syntax has these parts:

Part | Description
Application | Required, the top-level extensibility object.
Mode | Required, an enumerated type indicating the connection mode: ext_cm_AfterStartup, ext_cm_External, ext_cm_Startup, ext_cm_CommandLine.
AddinInst | Required, a pointer to the add-in.
Custom | Required Variant. Arguments to the add-in.

Remarks

Add-ins must implement this method.


OnDisconnection Method

The environment calls this method when it unloads the add-in.

Syntax

Sub OnDisconnection (ByVal RemoveMode As vbext_DisconnectMode, Custom() As Variant) As Object

This syntax has these parts:

Part | Description
RemoveMode | An enumerated type indicating the disconnection mode: HOST_SHUTDOWN, USER_SHUTDOWN
Custom | Reserved for future use.

Remarks

Add-ins must implement this method.


OnStartupComplete Method

The environment calls this method when startup is complete.

Syntax

Sub OnStartupComplete (Custom() As Variant)

This syntax has these parts:

Part | Description
Custom() | Reserved for future use.

Remarks

Add-ins must implement this method. It is in this method that the add-in can safely install user interface elements.


Open Method (ProjectItem Object)

Opens the ProjectItem object in the specified view. The resulting window should not be visible. To show the window to the user, set its Visible property to True.

Syntax

Function Open (ViewKind As String) As Window

This syntax has these parts:

Part | Description
ViewKind | Required GUID string specifying the kind of view to open. ProjectItem objects support at least the following: vsext_vk_Code, vsext_vk_Designer, and vsext_vk_Primary.

Remarks

This method may return an existing window if the ProjectItem object is already open in the specified view.

To change and save items without screen flickering, set the Visible property of the Window to False when it's opened, and then set Visible back to True after the item is saved.


Open Method (Solution Object)

Opens the Solution represented by the filename.

Syntax

Function Open (FileName As String) As Solution

This syntax has these parts:

Part | Description
FileName | Required String providing the full pathname.

Remarks

If a solution is already open, as determined by Get Solution returning non-NULL, then Open fails.


OpenFile Method

Opens a file as though the user invoked the File Menu’s Open File command.

Syntax

Method OpenFile(ViewKind As String, FileName As String) As Window

This syntax has these parts:

Part | Description
ViewKind | Required GUID string specifying the kind of view to open. The following, at a minimum, are supported: vsext_vk_Code, vsext_vk_Designer, and vsext_vk_Primary.
FileName | Required String providing the full pathname.

Remarks

If the file is part of a project, it is opened as a ProjectItem object. If the file is not part of a project, then it is opened in the miscellaneous files project.


Quit Method

Closes the environment.

Syntax

Method Quit()


Raise Method

Invokes a command.

Syntax

Sub Raise (Guid As String, ID As Long, CustomIn() As Variant, CustomOut() As Variant)

This syntax has these parts:

Part | Description
Guid | Required GUID string indicating the command group.
ID | Required Long. Index into the command group for the particular command.
CustomIn | Required Variant. Arguments passed in from OLECommandTarget. See OLE documentation for more information.
CustomOut | Required Variant. Arguments passed out and will be returned by OLECommandTarget. See OLE documentation for more information.

Remarks

Command groups are logical groupings of commands in the user interface. Within menus and toolbars, each group is denoted by a separator. Every command is assigned to a primary group. This primary group controls the command's position in the main menu structure and in the Customize dialog. Each command can be in multiple groups, such as on a main menu, on a context menu, and within a toolbar.


Remove Method

Removes an object from a collection.

Syntax

Sub Remove ()

Remarks

If the ProjectItems collection is populated, this method removes all members of the collection recursively.


Remove Method (LinkedWindows Collection)

Removes a Window object from the LinkedWindows collection.

Syntax

Sub Remove (ThisWindow As Window)

This syntax has these parts:

Part | Description
ThisWindow | Required. The window to be removed.

Remarks

The removed window becomes a floating window with its own LinkedWindowFrame.


Remove Method (Solution Object)

Removes a Project object from the Solution object.

Syntax

Sub Remove (proj As Project)

This syntax has these parts:

Part | Description
proj | Required. The Project object to remove.


SaveAs Method

Saves the project.

Syntax

Function SaveAs(NewFileName As String) As Boolean

This syntax has these parts:

Part | Description
NewFileName | Required String providing the filename.


SaveAs Method (Solution Object)

Saves the current solution file.

Syntax

Sub SaveAs (FileName As String)

This syntax has these parts:

Part | Description
FileName | Required String providing the filename.


SetFocus Method

Moves the focus to the specified window.

Syntax

Sub SetFocus ()


Update Method

Updates the collection as if the Add-in Manager Dialog was opened.

Syntax

Sub Update ()


AfterClosing Event

Occurs just after closing a Solution object.

Syntax

Event AfterClosing ( )

Remarks

This event is raised after closing the solution.


BeforeClosing Event

Occurs just before closing a Solution object.

Syntax

Event BeforeClosing ( )


BeforeExecute Event

Occurs before a command executes.

Syntax

Event BeforeExecute (guid As String, id As Long, ByRef handled As Boolean)

This syntax has these parts:

Part | Description
guid | GUID for the command set.
id | Index into the command set for the particular command.
handled | Indicates to other handlers that the command should be considered as having executed. True is passed if the handler implemented the command. False is passed if the handler just performed some auxiliary task.

Remarks

Before executing the function that is declared to be the implementation of a command, the BeforeExecute event occurs. Any number of listeners may be registered for the event. Each listener executes when the event occurs.

If a listener claims it has implemented the command no other listener or function should try to implement the command. A listener claims to have implemented the command by returning True for the handled parameter. If all a listener does is perform some extra function that in no way was supposed to be performing the command, such as make a log entry that the command fired, or perhaps increment a counter displayed somewhere, then the listener returns False for the handled parameter.


BuildDone Event

Occurs after building the solution.

Syntax

Event BuildDone (success As Boolean, updated As Boolean, cancelled As Boolean)

This syntax has these parts:

Part | Description
success | Boolean. True means the build succeeded, False means the build failed.
updated | Boolean. True means build or deploy products were modified. False means build or deploy products were not modified.
cancelled | Boolean. True means a user action cancelled the build. False means the build completed normally.

Remarks

Updated could be False while success is True, indicating that everything is up to date and no changes were made.


BuildStart Event

Occurs just before the solution builds.

Syntax

Event BuildStart ()


Click Event

Occurs when the OnAction property for the corresponding CommandBarControl object is set or returned.

Syntax

Event Click (ByVal CommandBarControl As CommandBarControl, ByRef handled As Boolean, ByRef CancelDefault As Boolean)

This syntax has these parts:

Part | Description
CommandBarControl | The source of the Click event.
handled | When the environment invokes the first handler for the Click event, it passes False for this argument. As each subsequent handler of the Click event is invoked, the environment passes the previous handler’s return value for this parameter. By convention, whenever this argument is True, the handler should do nothing.
CancelDefault | If a handler returns True through this parameter, then the environment should not invoke the built-in command. This parameter has no meaning for user-defined commands.


OnChanged Event

OnChange Event

Occurs just after the selection model changes.

Syntax

Event OnChange ( )

Remarks

Whenever something is selected in the development environment, a model of what the user has selected is created. A change in this model causes the OnChanged event to occur.


Opened Event

Occurs just after opening a solution.

Syntax

Event Opened ( )


ProjectAdded Event

Occurs just after adding a Project to the solution.

Syntax

Event ProjectAdded (object As Project)

This syntax has these parts:

Part | Description
object | This is the item just added.


ProjectRemoved Event

Occurs just after removing a Project from the solution.

Syntax

Event ProjectRemoved (object As Project)

This syntax has these parts:

Part | Description
object | This is the item just removed.


ProjectRenamed Event

Occurs just after renaming a Project.

Syntax

Event ProjectRenamed (object As Project, oldname As String)

This syntax has these parts:

Part | Description
object | This is the item just renamed.
oldname | String. The previous name of the Project.


QueryCloseSolution Event

Occurs just before triggering the BeforeClosing event.

Syntax

Event QueryCloseSolution (ByVar fCancel As Boolean)

This syntax has these parts:

Part | Description
fCancel | When True (default), solution closing is canceled. When False, solution closing is allowed to continue.


Renamed Event

Occurs just after renaming a solution.

Syntax

Event Renamed (oldname As String)

This syntax has these parts:

Part | Description
oldname | Required String. The previous name of the solution.


CommandInfo Method

Finds the command in the command group associated with the given CommandBarControl and returns the command's GUID and ID.

Syntax

Function CommandInfo(CommandBarControl As CommandBarControl, GUID As String, ID As Long)

The syntax has these parts:

Part | Description
CommandBarControl | Required. The CommandBarControl associated with the command.
GUID | Required String. ByRef argument for passing back the command’s GUID
ID | Required Long. ByRef argument for passing back the command’s ID.


IsOpenFile Property

Returns True if the file is open in the specified view.

Syntax

Property Get IsOpenFile(View As String, FileName As String) As Boolean

This syntax has these parts:

Part | Description
View | Required GUID String specifying the kind of view to open. At a minimum, the following are supported: vsext_vk_Code, vsext_vk_Designer, and vsext_vk_Primary.
FileName | Required String providing the full pathname of the file.