Partilhar via


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

Comments

  • Anonymous
    May 29, 2006
    I finally finished writing HTML spell checker add-on to Visual Studio. Spell checker works in Source...
  • Anonymous
    June 14, 2006
    The comment has been removed
  • Anonymous
    June 15, 2006
    There is a link in the beginning of the entry:

    http://blogs.msdn.com/mikhailarkhipov/archive/2006/04/17/577471.aspx
  • Anonymous
    June 28, 2006
    The comment has been removed