Solved

Spelling

Posted on 2000-04-14
5
417 Views
Last Modified: 2008-02-20
I want to spell check individual words, just to find out if they are correctly spelt words, I'm not interested in spelling suggestions.  I don't want to spend any money on components, I currently have Word2000, and I need to do this from inside a COM object, so no form to host an ActiveX control.  What is the easiest way to do this?

Cheers
0
Comment
Question by:ch52jb
  • 3
  • 2
5 Comments
 

Expert Comment

by:yuxiliu
ID: 2719996
I have office 97 installed, I think Off2000 is same.
if you are using MFC, follow this way:
classWizard -> add new class -> add by type lib -> browser -> office dir-> office -> MSWORD8.olb(you need check what is in off2000) -> "_Application".
at this point you get a wrapper class of word, you can use the method in this interface:

BOOL _Application::CheckSpelling(LPCTSTR Word, VARIANT* CustomDictionary, VARIANT* IgnoreUppercase, VARIANT* MainDictionary, VARIANT* CustomDictionary2, VARIANT* CustomDictionary3, VARIANT* CustomDictionary4, VARIANT* CustomDictionary5,
            VARIANT* CustomDictionary6, VARIANT* CustomDictionary7, VARIANT* CustomDictionary8, VARIANT* CustomDictionary9, VARIANT* CustomDictionary10)
{
      BOOL result;
      static BYTE parms[] =
            VTS_BSTR VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT;
      InvokeHelper(0x144, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
            Word, CustomDictionary, IgnoreUppercase, MainDictionary, CustomDictionary2, CustomDictionary3, CustomDictionary4, CustomDictionary5, CustomDictionary6, CustomDictionary7, CustomDictionary8, CustomDictionary9, CustomDictionary10);
      return result;
}


first param is the word you want check, "CustomDictionary" is the file of "*.dic" you can search in office directory. if word has error return FALSE otherwise return TRUE.

if you want use raw COM, by this way:

#import "...\MSWORD8.OLB" // you need check what's the type lib name is in off2000

IWordApplication* pWordApplication; // note: you need to check the IID of on your computer as you are using off2000
CoCreateInstance(CLSID_WordApplication, NULL, CLSCTX_ALL, IID_IWordApplication(void**) &pWordApplication); // get the interface point of word application.

if(pWordApplication->CheckSpelling(L"TestWord","CustomDic1", "CustomDic2"...))
{
//correct spelling
}
else
{
//wrong spelling
};
pWordApplication->Release();
0
 

Accepted Solution

by:
yuxiliu earned 100 total points
ID: 2719997
I have office 97 installed, I think Off2000 is same.
if you are using MFC, follow this way:
classWizard -> add new class -> add by type lib -> browser -> office dir-> office -> MSWORD8.olb(you need check what is in off2000) -> "_Application".
at this point you get a wrapper class of word, you can use the method in this interface:

BOOL _Application::CheckSpelling(LPCTSTR Word, VARIANT* CustomDictionary, VARIANT* IgnoreUppercase, VARIANT* MainDictionary, VARIANT* CustomDictionary2, VARIANT* CustomDictionary3, VARIANT* CustomDictionary4, VARIANT* CustomDictionary5,
VARIANT* CustomDictionary6, VARIANT* CustomDictionary7, VARIANT* CustomDictionary8, VARIANT* CustomDictionary9, VARIANT* CustomDictionary10)
{
BOOL result;
static BYTE parms[] =
VTS_BSTR VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT;
InvokeHelper(0x144, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
Word, CustomDictionary, IgnoreUppercase, MainDictionary, CustomDictionary2, CustomDictionary3, CustomDictionary4, CustomDictionary5, CustomDictionary6, CustomDictionary7, CustomDictionary8, CustomDictionary9, CustomDictionary10);
return result;
}


first param is the word you want check, "CustomDictionary" is the file of "*.dic" you can search in office directory. if word has error return FALSE otherwise return TRUE.

if you want use raw COM, by this way:

#import "...\MSWORD8.OLB" // you need check what's the type lib name is in off2000

IWordApplication* pWordApplication; // note: you need to check the IID of on your computer as you are using off2000
CoCreateInstance(CLSID_WordApplication, NULL, CLSCTX_ALL, IID_IWordApplication(void**) &pWordApplication); // get the interface point of word application.

if(pWordApplication->CheckSpelling(L"TestWord","CustomDic1", "CustomDic2"...))
{
//correct spelling
}
else
{
//wrong spelling
};
pWordApplication->Release();


0
 

Expert Comment

by:yuxiliu
ID: 2720001
Sorry, CreateInstance should be:
CoCreateInstance(CLSID_WordApplication, NULL, CLSCTX_ALL, IID_IWordApplication,(void**) &pWordApplication);
0
 

Author Comment

by:ch52jb
ID: 2722288
I'f tried importing the type library, and I'm calling the create application function.  For any parameters I don't want, I'm using NULL.  However, I always get a return code of -858993460 no matter if the word is spelt right or wrong.  Any ideas why this is happening?
0
 

Author Comment

by:ch52jb
ID: 2898020
Answer accepted
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now