Running HTML Spell checker on all ASP.NET and HTML files in the solution

If you want to run HTML Spell checker on all aspx, ascx, htm and html files in the solution, you can use the following macro.

1. Click Tools | Macros | Macro IDE
2. Select MyMacros node
3. Click Project | Add Module
4. Specify SpellChecker as module name and click OK
5. Replace module content with the code below
6. Click File | Save MyMacros and exit Macro IDE
7. Click Tools | Macros | Macro Explorer
8. Open MyMacros | SpellChecker node
9. Right-Click on the SpellCheckSolution and choose Run

The macro iterates through files and folders in the solution and run spell checker on every file. You can see progress in the Output Window (View | Output Window). Results should appear in the Visual Studio Error List window.

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module SpellChecker
Private _outputWindow As OutputWindowPane

Public Sub SpellCheckSolution()
_outputWindow = GetOutputWindowPane("HTML Spell Checker")
_outputWindow.OutputString("Running spell check on files in the solution..." + vbCrLf)

For Each project As Project In DTE.ActiveSolutionProjects
_outputWindow.OutputString("Spell check complete." + vbCrLf)
End Sub

Private Sub ProcessProjectItemCollection(ByVal projItemsCollection As ProjectItems)

For Each pi As ProjectItem In projItemsCollection
If Not pi.ProjectItems Is Nothing Then
If pi.Kind = Constants.vsProjectItemKindPhysicalFile And _
(pi.Name.EndsWith("aspx") Or pi.Name.EndsWith("ascx") Or _
pi.Name.EndsWith("html") Or pi.Name.EndsWith("htm")) Then

Dim window As Window = pi.Open(Constants.vsViewKindTextView)
window.Visible = True
_outputWindow.OutputString(pi.Name + vbCrLf)
End If
End If
End Sub

Private Function GetOutputWindowPane(ByVal Name As String) As OutputWindowPane
Dim window As Window
Dim outputWindow As OutputWindow
Dim outputWindowPane As OutputWindowPane

window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
window.Visible = True
outputWindow = window.Object
outputWindowPane = outputWindow.OutputWindowPanes.Item(Name)
Catch e As System.Exception
outputWindowPane = outputWindow.OutputWindowPanes.Add(Name)
End Try
Return outputWindowPane
End Function

End Module

Comments (4)

  1. I finally finished writing HTML spell checker add-on to Visual Studio. Spell checker works in Source…

  2. john barton says:

    This seems to be a great little macro, but I think I’m missing something.

    The macro is failing at DTE.ExecuteCommand("HTMLSpellChecker.Connect.HTMLSpellChecker")

    with a message of "Error HRESULT E_FAIL has been returned from a call to a com component.

    Where can I find the HTMLSpellChecker component.

    Many thanks


  3. Pintea says:

    Followed all the steps at "Spell Checker for HTML and ASP.NET pages"

    An Error "Error HRESULT E_FAIL has been returned from a call to a com component.

    What should be done to fix the above? Pls help

Skip to main content