Microsoft KB Archive/152578

= OFF95: Macro to Spell Check a Binder =

Article ID: 152578

Article Last Modified on 8/17/2005

-

APPLIES TO


 * Microsoft Office 95 Standard Edition
 * Microsoft Office 95a
 * Microsoft Office 95b

-



This article was previously published under Q152578





SUMMARY
By default, spell checking is not provided across all sections of a binder. If you want to check the spelling of each section in your binder, you must first activate each section and then check the spelling while the document is activated.

This article provides a sample Microsoft Excel Visual Basic for Applications macro for checking the spelling of all the Microsoft Word and Microsoft Excel sections in a binder file. Note, since Microsoft PowerPoint does not have a Spell checking method in its Object model, the macro does not contain any code to check the spelling of PowerPoint presentations.



MORE INFORMATION
Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support professionals can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

Before entering the sample macro code below, do the following:

 Open a new binder document. Add a new Microsoft Word 6.0 Document section to the binder. Enter the misspelled word "dogg", without quotes, in your Word document. Add a new Microsoft Excel 5.0 Worksheet section to the binder. Enter the misspelled word "catt", without quotes, in cell A1. With the Microsoft Excel section active, click View Outside on the Section menu.

Step 6 is necessary to add a module sheet to the Microsoft Excel section and to be able to enter macro code into the module sheet.</li>  Insert a module sheet in the workbook, and enter the following code into the module sheet: Sub Check_Spelling_In_Binder Dim BindObj As Object Dim WrdBasic As Object Dim BindSct On Error Resume Next 'Create a reference to the Binder Set BindObj = ActiveWorkbook.Container.Parent active_section = BindObj.ActiveSection.Name 'Loop through all of the Binder sections. For Each BindSct In BindObj.sections BindSct.Activate '"If" structure to determine type of section If BindSct.Type Like "Excel.Sheet.*" Then BindSct.Object.Cells.CheckSpelling _ customdictionary:="custom.dic", _ ignoreuppercase:=False, alwayssuggest:=True ElseIf BindSct.Type Like "Word.Document.*" Then ' If Word.Basic object not created, create it               If WrdBasic Is Nothing Then Set WrdBasic = _ CreateObject("word.basic") WrdBasic.toolsspelling ElseIf BindSct.Type Like "Excel.Chart.*" Then BindSct.Object.CheckSpelling _ customdictionary:="custom.dic", _ ignoreuppercase:=False, alwayssuggest:=True Else 'This would be a PowerPoint section. 'No Spell check method in Powerpoint object model. End If       Next BindSct 'reactivate the section from which this macro was launched BindObj.sections(active_section).Activate Set BindObj = Nothing Set WrdBasic = Nothing End Sub </li> On the File menu click Close to return to the Binder.</li> On the Tools menu click Macro and in the Macro dialog box double- click the macro "Check_Spelling_In_Binder" to run the macro.</li></ol>

The macro should run and the spelling checker for both Word and Microsoft Excel should come up while the respective binder section is active and tell you that it found a misspelled word. When the macro has finished, the section that was active when you ran the macro will be activated.

<div class="references_section">