Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Spelling

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

808 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