Hello,
We could invoke the spell check command created by the spell checker Add-in in our add-in. All we need to do is open all the files in our project, and invoke the spell checker command.
Here is the sample code.
//Get the spell checker command first.
Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];
CommandBarControl toolsControl = menuBarCommandBar.Controls["Tools"];
CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;
CommandBarControl spellCheckControl = toolsPopup.Controls["Spell Checker"];
CommandBarButton spellCheckerBtn = (CommandBarButton)spellCheckControl;
// spellCheckerBtn.Execute();
Project prj = _applicationObject.Solution.Projects.Item(1);
UIHierarchy hierachy = prj.Object as UIHierarchy;
//invoke command for each open document.
foreach (ProjectItem prjItem in prj.ProjectItems)
{
if (prjItem.Kind.Equals(Constants.vsProjectItemKindPhysicalFile))
{
prjItem.Open(Constants.vsViewKindPrimary);
prjItem.Document.Activate();
//This is used to wait for the document to be opened completely.
System.Threading.Thread.Sleep(1000);
spellCheckerBtn.Execute();
}
}
But the code is not complete, to have all the project items open, you must use a recursive function to get the projectItems in a winform designer or in a folder.
Thanks
Chao