Spell checker supports text verification in:
- HTML and ASP.NET element content and attributes
- HTML style comments <-- HTML -->
- ASP.NET server side comments: <%-- ASP.NET --%>
- JScript, C# and C++ comments: // C++ style comments
- CSS and C style comments: /* C style comments */
- VB and VBScript style comments: 'This is VB comment
Spell checking is supported in style and script blocks as well as in JS, CS, VB, CSS, CPP and H files. Spell checker is able to detectslang attribute specified on HTML elements, extract ISO language and use it to specify appropriate dictionary for the Office spell checking engine. SeeWeb Development Tools team blog post for more details as well as included readme.htm file.
Requirements:
Microsoft Visual Studio 2010 RTM, any edition except Express.
Microsoft Word 2003, 2007 or 2010
Running spell check on all files in solutions
You can try using 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
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
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("Tools.SpellChecker")
'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