Visual Studio 2008 allows one to open an existing website by navigating File > Open > WebSite.  Alternatively, one may also use the following shortcut: Shift + ALT + O.  image

But let’s say you would like to open a website by a right-click folder option. Here’s how to do it using a VS Macro and a Registry Entry: 

Open Visual Studio.  Select Tools > Macros > Macros IDE.  Right-click “MyMacros” and select “New module…” At the prompt, name the module “Website”. Add the VsWebSite.Interop.dll reference(Projects > Add Reference) and copy/paste the follow code over the generated Public “Website” module.

Imports System
Imports EnvDTE
Imports EnvDTE80Imports EnvDTE90
Imports System.Diagnostics

Public Module Website

    Sub OpenWebsite(Optional ByVal path As String = “”)

        If (String.Compare(path, String.Empty) = 0) Then
           
MsgBox(“Must supply a folder path to the OpenWebsite macro”,
            MsgBoxStyle.OkOnly)
        Else
            Dim
webPkg As VsWebSite.VSWebPackage
            webPkg = DTE.GetObject(“WebPackage”)
            webPkg.OpenWebSite(path,
            VsWebSite.OpenWebsiteOptions.OpenWebsiteOption_None, False)
        End If

    End Sub

End Module

Now register a shell command enabling an “Open as VS2008 Website” option on any folder in Windows Explorer.  Simply, copy/paste the following script into a new “OpenWebsiteVS2008.reg” file.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\OpenVS2008Web]
@=”Open as VS2008 Website”

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\OpenVS2008Web\command]
@=”\”C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\devenv.exe\”
/command \\\”Macros.MyMacros.Website.OpenWebsite %1\\\”"

Execute (double-click) the file to update the Registry accordingly.  The “Open as VS2008 Website” option will now be available in Windows Explorer.

2 Comments to “Open VS2008 WebSite Macro”

  1. Ralph N says:

    That’s pretty damn useful.

  2. God bless you
    Please I want to have website with this
    Name www. christisalive.co.uk

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>