VB calls the word spell check feature instance _vb

Source: Internet
Author: User

As we all know, Word has its own spell checking feature. VB to implement the call Word spell check function is very simple to achieve, the way is to create Word objects, and then put the need to check the string into Word, call the word spell check, then remove the return value, and finally close the object.

The specific implementation code for each step is shown below:

Function Checkspell (Incorrecttext As String) As String
Dim Word as Object, rettext$ on 
Error Resume Next 
' Build wo Rd object and open
Set Word = CreateObject ("Word.Basic")

' put the STRING you want to check into Word
word.appshow
word.filenew
Word.Insert incorrecttext

' calls Word spelling checker 
word.toolsspelling
word.editselectall

' gets the return value 
Rettext = word.selection$ ()
Checkspell = left$ (Rettext, Len (Rettext)-1)

' closes file
word.fileclose 2 
Show

Set Word = no end
Function

This example has detailed comments to help readers understand, in addition to the reader can also be based on this example to see other materials for further improvement to achieve more powerful features!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.