How to: Use a Macro to Display Information About a Help Topic
The Help2 object is a child of DTE in its object hierarchy and can be accessed by using the late-bound DTE.Help property. In macros, references to the main automation libraries (EnvDTE and EnvDTE80) are already provided and can be accessed immediately.
The following procedure explains how to access methods and properties of the Help2 object in a Visual Studio macro.
To program with the Help2 object in a Visual Studio macro
On the Tools menu, point to Macros, and then click Macros IDE.
The Macros IDE appears.
On the View menu of the Macros IDE, click Project Explorer.
In Project Explorer, double-click MyMacros.
Double-click Module1.
Add the following sub to the module:
Public Module Module1 ' Macro sub that exercises the Help object. Sub HelpObject() ' Get the Help object. Dim obj As Object = DTE.Help MsgBox("The Help collection is: " & vbCr & obj.Collection) MsgBox("Displaying the favorites window...") obj.Favorites() MsgBox("Displaying the How Do I window...") obj.HowDoI() MsgBox("Displaying a topic via URL") ' The URLs are subject to change and may not work. obj.DisplayTopicFromURL _ ("ms-help://MS.VSCC.v80/MS.VSIPCC.v80/ _ MS.VSIP.v80/dv_vstudiosdk/html/ _ 1f7c348a-114c-4243-b392-3531e9c9c6fd.htm") MsgBox("Synchronizing contents and showing the contents window") obj.SyncContents("ms-help:// _ MS.VSCC.v80/MS.VSIPCC.v80/MS.VSIP.v80/ _ dv_vstudiosdk/html/ _ 1f7c348a-114c-4243-b392-3531e9c9c6fd.htm") obj.Contents() MsgBox("Showing the search results window") obj.SearchResults() End Sub End Module
The URLs for Help topics may not work in your version of Visual Studio. To pick a different URL, display a Help topic in Microsoft Document Explorer and select the URL from the URL drop-down menu.
On the Debug menu, click Start to run the macro.
When the Microsoft Document Explorer opens to display a Help topic, or to set focus on a particular feature of the Document Explorer, close it to go through each step in the macro.
See Also
Concepts
Automating Repetitive Actions by Using Macros
Other Resources
Automation and Extensibility for Visual Studio