Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

GetSpellingSuggestions fails with custom dictionary

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Hinton - 16 Feb 2006 21:04 GMT
I am running into an issue with the GetSpellingSuggestions method.  If I call
it without specifying a custom dictionary, the call works find and returns a
list of words as expected.  However, if I provide the path to a custom
dictionary it fails with an HR of 0x800a239d (which I can find no reference
to anywhere).

Here is the code that displays the error...  If I make the 'dictionary'
variant vtMissing, the GetSpellingSuggestions works perfectly.  Anybody have
any suggestions (pun intented)...

STDMETHODIMP CSpellChecker::GetSpellingSuggestions
(
  BSTR word,
  BSTR customDictionary,
  ISpellingSuggestions **suggestions
){
  HRESULT               returnValue;
  MSWord::_ApplicationPtr   spellChecker = _Module.getMSWordApplication();

  if( NULL == spellChecker )
  {
     returnValue = E_UNEXPECTED;
  }
  else if( NULL == word ||
         NULL == suggestions )
  {
     returnValue = E_POINTER;
  }
  else
  {
     try
     {
        _variant_t   ignoreUppercase( m_ignoreUppercase );
        _variant_t   dictionary = validateCustomDictionary(
customDictionary ) ? _variant_t(customDictionary) : vtMissing;

        MSWord::SpellingSuggestionsPtr sug =
spellChecker->GetSpellingSuggestions( word, &dictionary, &ignoreUppercase );

        CSpellingSuggestions * cSug = new CComObject<CSpellingSuggestions>;

        cSug->SetSuggestions( sug );

        *suggestions = cSug;
        (*suggestions)->AddRef();

        returnValue = S_OK;
     }
     catch( const _com_error & e )
     {
        _bstr_t   message( e.ErrorMessage() );
        _bstr_t desc( e.Description() );
        OutputDebugString( e.ErrorMessage() );
        OutputDebugString( "\n" );

        returnValue = E_FAIL;
     }
  }

  return( returnValue );
}
Chris Hinton - 17 Feb 2006 18:28 GMT
Just a little follow up information.  Elsewhere, I have a call to
CheckSpelling that works perfectly well with the custom dictionary parameter.
That is, it does not flag words that are in my custom dictionary as
misspelled.

This code works without error:
_variant_t    ignoreUppercase( m_ignoreUppercase );
_variant_t    dictionary = validateCustomDictionary( customDictionary ) ?
customDictionary : vtMissing;
*returnValue = spellChecker->CheckSpelling( word, &dictionary,
&ignoreUppercase );
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.