For more information see http://blogs.msdn.com/webdevtools/archive/2008/11/29/spell-checker-update-2-2-full-support-for-vs-2008-sp1-simpler-setup-and-a-few-bug-fixes.aspx
Requires VS 2008 SP1, Office 2003, 2007 or 2010. Not compatible with VS 2008 RTM.
To run spell check on all files in solution try the following macro
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.Solution.Projects
If Not project.ProjectItems Is Nothing Then
ProcessProjectItemCollection(project.ProjectItems)
End If
Next
_outputWindow.OutputString("Spell check complete." + vbCrLf)
End Sub
Private Sub ProcessProjectItemCollection(ByVal projItemsCollection As ProjectItems)
For Each pi As ProjectItem In projItemsCollection
Dim childrenCount = 0
If Not pi.ProjectItems Is Nothing Then
childrenCount = pi.ProjectItems.Count
End If
If childrenCount = 0 Then
If pi.Kind = Constants.vsProjectItemKindPhysicalFile And IsKnownFileType(pi.Name) Then
Try
Dim window As Window
Dim opened As Boolean = False
If pi.Document Is Nothing Then
window = pi.Open(Constants.vsViewKindTextView)
'opened = True
Else
window = pi.Document.ActiveWindow
If (window Is Nothing) Then
window = pi.Open(Constants.vsViewKindTextView)
End If
End If
window.Visible = True
window.Activate()
_outputWindow.OutputString(pi.Name + vbCrLf)
DTE.ExecuteCommand("VSSpellCheckerAddIn.Connect.VSSpellCheckerAddIn")
'If Not window.Caption.Contains("*") And opened = True Then
'window.Close()
'End If
Catch ex As Exception
_outputWindow.OutputString("Could not check " + pi.Name + ", exception " + ex.Message + vbCrLf)
End Try
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
Private Function IsKnownFileType(ByVal name As String) As Boolean
Dim knownExtensions() As String = New String() {".cs", ".vb", "htm", ".html", ".css", ".inc", ".js", ".vbs", _
".aspx", ".asp", ".ascx", ".ashx", ".asmx", _
".cpp", ".h", ".hpp", ".hxx"}
For Each ext As String In knownExtensions
If name.EndsWith(ext) Then
Return True
End If
Next
Return False
End Function
End Module