Ver versión en español    
 
Home
10 Reasons to use MZ-Tools
MZ-Tools 6.0 for VS.NET
Editions
Features
Online Documentation
MZ-Tools SDK
Download
Purchase
FAQ & Support
Version History
MZ-Tools 3.0 for VB6 & VBA
Features
Online Documentation
Download (freeware)
Donations (Paypal)
FAQ & Support
Version History
User Reviews
Community Place
Contact  
For Add-In Developers
About
   
 
User Testimonials

I'm an avid supporter of MZ-Tools. It's a product I couldn't do without and your level of support is outstanding.

Jan Hyde (Visual Basic MVP)

You will soon wonder how you ever lived without it.

Andy Maggs

More user reviews
 
HOWTO: Open the Web Browser and navigate to a page from a Visual Studio add-in or macro

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Visual Studio .NET 2002
Date: May 2008   Microsoft Visual Studio .NET 2003
      Microsoft Visual Studio 2005
      Microsoft Visual Studio 2008
Introduction

This article explains how to open the Web Browser window of Visual Studio and navigate to a web site.

More Information

To open the Web Browser window of Visual Studio and navigate to a web site you have to use the following method of the Visual Studio automation model (EnvDTE):

 EnvDTE.DTE.ItemOperations.Navigate(url, options)

The method receives as parameters the URL and the navigation options (EnvDTE.vsNavigateOptions enumeration) and it returns the EnvDTE.Window of the Web browser.

The following code shows an add-in that navigates to the Microsoft web site when loaded:

Imports System
Imports Microsoft.VisualStudio.CommandBars
Imports Extensibility
Imports EnvDTE

Public Class Connect
   Implements IDTExtensibility2

   Private m_objDTE As DTE

   Public Sub OnConnection(ByVal application As Object, ByVal connectMode As ext_ConnectMode, _
      ByVal addInInst As Object, ByRef custom As Array) _
      Implements IDTExtensibility2.OnConnection

      m_objDTE = CType(application, EnvDTE.DTE)

      Select Case connectMode

         Case ext_ConnectMode.ext_cm_AfterStartup
            Initialize()

         Case ext_ConnectMode.ext_cm_Startup
            ' OnStartupComplete will be called
      End Select

   End Sub

   Public Sub OnStartupComplete(ByRef custom As Array) Implements IDTExtensibility2.OnStartupComplete
      Initialize()
   End Sub

   Public Sub OnDisconnection(ByVal disconnectMode As ext_DisconnectMode, ByRef custom As Array) _
      Implements IDTExtensibility2.OnDisconnection
   End Sub

   Public Sub OnAddInsUpdate(ByRef custom As Array) _
      Implements IDTExtensibility2.OnAddInsUpdate
   End Sub

   Public Sub OnBeginShutdown(ByRef custom As Array) _
      Implements IDTExtensibility2.OnBeginShutdown
   End Sub

   Private Sub Initialize()

      Dim objWindow As EnvDTE.Window

      objWindow = m_objDTE.ItemOperations.Navigate("http://www.microsoft.com", vsNavigateOptions.vsNavigateOptionsNewWindow)

   End Sub

End Class

Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this

MZ-Tools 6.0 for Visual Studio .NET

You can code, design, locate code and document your apps much faster using VB.NET, C#, C++ or Visual J#:

Buy MZ-Tools Now Download MZ-Tools Demo

   Top