Welcome to MSDN Blogs Sign in | Join | Help

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.Clear()
        _outputWindow.OutputString("Running spell check on files in the solution..." + vbCrLf)

        For Each project As Project In DTE.ActiveSolutionProjects
            ProcessProjectItemCollection(project.ProjectItems)
        Next
        _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
                    window.Activate()
                    _outputWindow.OutputString(pi.Name + vbCrLf)
                    DTE.ExecuteCommand("HTMLSpellChecker.Connect.HTMLSpellChecker")
                End If
            Else
                ProcessProjectItemCollection(pi.ProjectItems)
            End If
        Next
    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
        Try
            outputWindowPane = outputWindow.OutputWindowPanes.Item(Name)
        Catch e As System.Exception
            outputWindowPane = outputWindow.OutputWindowPanes.Add(Name)
        End Try
        outputWindowPane.Activate()
        Return outputWindowPane
    End Function

End Module

Published Monday, May 29, 2006 6:08 PM by Mikhail Arkhipov (MSFT)

Comments

# Spell Checker for HTML and ASP.NET pages

I finally finished writing HTML spell checker add-on to Visual Studio. Spell checker works in Source...
Monday, May 29, 2006 9:28 PM by Mikhail Arkhipov (MSFT)'s WebLog

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

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
John
Thursday, June 15, 2006 6:14 AM by john barton

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

There is a link in the beginning of the entry:

http://blogs.msdn.com/mikhailarkhipov/archive/2006/04/17/577471.aspx
Thursday, June 15, 2006 8:06 AM by Mikhail Arkhipov (MSFT)

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

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
Wednesday, June 28, 2006 2:31 PM by Pintea
New Comments to this post are disabled
 
Page view tracker