CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2001
    Posts
    11

    Writing Unicode Data onto MS-Word

    Hey..!

    Once again..!!

    Well, this time around, its about using the "Word.Application.8" component for writing the unicode data onto the word document, by replacing a book mark. Im getting the data as junk on the document. My code looks like the following:

    _variant_t y((long) i, VT_I4);
    BookmarkPtr bptr = bookptr->Item (&y);
    RangePtr rp = bptr->GetRange ();
    _bstr_t input_string(data);
    rp->PutText (input_string);

    The data sent to the PutText function is always wchar_t. My compute locale is US American. The GetLanguageID returns me wdEnglishUS as my language. Im not able to chage this language by calling PutLanguageID. The result of the language ID always remains wdEnglishUS even after setting it a different language. I checked it by doing the following,

    WdLanguageID id = rp->GetLanguageID();
    bptr->PutLanguageID(wdArabic);
    id = rp->GetLanguageID();

    Come on guys..! Im frustrated. Any suggestions?

  2. #2
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588
    It looks correct to me. What kind of junk are you getting? Does it look like Word has converted it to ANSI, does the font not display it correctly, does it look like it's interpreting the Unicode string as ANSI (i.e. twice the length) or none of the above?

    I don't think you have to change the language in order to make Word display Unicode correctly, but I could be wrong.

    Lastly, is it localised to Arabic, or does it also happen with e.g. Cyrillic and Chinese?
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  3. #3
    Join Date
    Nov 2001
    Posts
    11

    Unhappy Writing Unicode Data onto MS-Word

    Junk looks the ANSI equivalent of the Unicode Data. Later I changed converting the font of string in the document by using MS-Word Editor and the characters still looked the same.

    Changing the Language was an option I tried to findout if I am making a mistake. That too didnt work and strangely the language never found to be changing either.

    And it is NOT localized to any language. Cyrillic, Chinese and even Western European Characters.

    Its so frustrating..!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured