Leverage Office to Spellcheck RichText

Integrate Microsoft Word 97’s spellchecking capability into VB apps while maintaining formatting within a rich textbox. To test this code:
1. Create a standard EXE project in VB.
2. Add the RichTextBox control from the Components menu.
3. Add a reference to the Microsoft Word 8.0 Object Library.
4. Drop a RichTextBox and a CommandButton onto the form.
5. Rename the RichTextBox to rtfText.
6. Change the caption of the CommandButton to Spell Check.
7. In the Click event of the CommandButton, add the next code listing.
8. Save and run the project.
9. Type some text in the RTF box and click on the CommandButton to check the spelling.

 On Error GoTo SpellCheckErr	Dim oWord As Object	Set oWord = CreateObject("Word.Application")	'Save the RTF Box contents to a temporary file	rtfText.SaveFile "C:TEST.RTF", rtfRTF	'Open the saved document and spellcheck it	oWord.Documents.Open ("C:TEST.RTF")	oWord.ActiveDocument.SpellingChecked = False	oWord.Options.IgnoreUppercase = False	oWord.ActiveDocument.CheckSpelling	'Save the changes to the RTF file & close	oWord.ActiveDocument.Save	oWord.ActiveDocument.Close	oWord.Quit	'Load the changes back to the rtf text box.	rtfText.LoadFile "C:TEST.RTF", rtfRTF	Set oWord = Nothing	Screen.MousePointer = vbDefault	MsgBox "Spell Check is complete", _		vbInformation, "Spell Check"	Exit SubSpellCheckErr:	MsgBox Err.Description, vbCritical, _		"Spell Check"	Set oWord = Nothing
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

technology leadership

Why the World Needs More Technology Leadership

As a fact, technology has touched every single aspect of our lives. And there are some technology giants in today’s world which have been frequently opined to have a strong influence on recent overall technological influence. Moreover, those tech giants have popular technology leaders leading the companies toward achieving greatness.

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job