July 27th, 2011, 05:33 AM
Spell check using MFC and MS word 2010
We are accessing ms word using MFC in our C++ application. Using MFC AppWzizard(dll) and with office14 type library(MS Word 2010), a regular MFC static dll has been created and linked our application.
Using MS word for spellchecking functionality.
I am using CheckSpelling function API of ms word as below for spell check.
Application.CheckSpelling(Word, CustomDictionary, IgnoreUppercase, MainDictionary, CustomDictionary2, CustomDictionary3, CustomDictionary4, CustomDictionary5, CustomDictionary6, CustomDictionary7, CustomDictionary8, CustomDictionary9, CustomDictionary10)
The CustomDictionary represents the name of the .dic file name to which the application would refer while checking for spelling and IgnoreUppercase is a flag to ignore the uppercase characters.
In word 2003, CheckSpelling() API works independently referring only to the custom dictionaries mentioned as parameters and it considers IgnoreUppercase parameter for ignoring the uppercase characters.
However in word 2010, CheckSpelling() API depends on the settings of MS word. This API also refers to the custom dictionaries already set in MS word application along with the custom dictionaries sent as parameters. And also the parameter IgnoreUppercase does not have any influence. Ignoring uppercase works based on the settings that are done in ms word.
While referring to the already set custom dictionaries during spell check, default dictionary is ignored. So, there must be some way of ignoring all other custom dictionaries that are already set. And also to make IgnoreUppercase parameter work.
The statement I am using is as below.
bool res = m_word.CheckSpelling((LPCTSTR) text, strFilename, m_vFalse, m_vOpt, m_vOpt, m_vOpt, m_vOpt, m_vOpt, m_vOpt, m_vOpt, m_vOpt, m_vOpt, m_vOpt);
text- has the word for spell check.
strFilename – is COleVariant. COleVariant strFilename ((LPCTSTR) Filename). And Filename is Cstring of the location of Custom dictionary.
m_vFalse - COleVariant((short) FALSE);
m_vOpt = COleVariant((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
Please let me know if I am calling the API with correct parameters or any modification needs to be made.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!