Udostępnij za pośrednictwem


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

  1. On the Tools menu, point to Macros, and then click Macros IDE.

    The Macros IDE appears.

  2. On the View menu of the Macros IDE, click Project Explorer.

  3. In Project Explorer, double-click MyMacros.

  4. Double-click Module1.

  5. 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.

  6. On the Debug menu, click Start to run the macro.

  7. 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

Programmatically Interacting with Document Explorer

Microsoft Document Explorer Overview