Solved

Spelling

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lambda for random numbers problem 7 106
Focus not getting shifted out of  editbox 2 57
IdTCPClient1->Disconnect(); not working 3 59
What is sub-make ? 2 37
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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

929 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

13 Experts available now in Live!

Get 1:1 Help Now