Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Expertise: Intermediate
Oct 20, 1999



Application Security Testing: An Integral Part of DevOps

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

	'Save the changes to the RTF file & close

	'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 Sub

	MsgBox Err.Description, vbCritical, _
		"Spell Check"
	Set oWord = Nothing
Rohit Kapoor
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date