Solved

Spelling

Posted on 2000-04-14
5
421 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

785 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