Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Atlanta, Georgia, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Different languages in MsgBox text? (Word 2003)

    A client wants to translate a Word form into multiple languages, and wants the prompts and warnings to be translated as well. I've never tried that, and I'm not sure what's required.

    They want Spanish, French, Portuguese, and Simplified Chinese. Do I need a language pack for each language in order to get the characters to display in a MsgBox prompt? The VBE doesn't like the various characters I've tried to paste into it.

    What are my options?

    Thanks,
    Bob
    Writing Consultant / Word Template Designer
    Words Connect

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    I'd put the languages into text files, each string on a separate line, enclosed in double quotes, separated by some character you pick.
    Then read the text file into a string array:

    In the intialise event of the forms and in all message boxes you use this array (or a collection, or whatever scheme you pick) to set the Captions and ToolTip Texts etc. of all controls, depending on a language index you have set somewhere. My Excel Name Manager uses this trick and I've posted an Excel method here:
    http://www.jkp-ads.com/articles/distributemacro09.asp
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    I have done this in the past by defining each text string as an array, with English as the first string, French as the second etc. I then defined a global variable as the language number so that I could select the correct character strings at run time.

    Be very careful with any text that is not standard ASCII in the visual basic editor. I once discovered that the combination of characters that looks like e-acute followed by a closing quote in VBA on my PC comes out as a valid 16 bit character in Japanese. This resulted in syntax errors due to unterminated strings and I had all the fun of debugging my code remotely on a PC that displayed only Japanese error messages!

    I never did find out the correct way to define string constants with accented characters to avoid this problem, so I ended up with the very ugly workaround of never having a string that ended with ť" (I just added a space between the ť and the ")

    StuartR

  4. #4
    2 Star Lounger
    Join Date
    May 2002
    Location
    Atlanta, Georgia, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    Thanks for the replies, though I'm not sure I've got it. I don't think I will be able to enter Simplified Chinese into the VBE, though. I tried today (at least by copying text the characters from a Word doc and pasting into the VBE. All I got was ??????, though. Not very helpful as a prompt. :-D But you were able to do some accented characters in the VBE? I guess I could do some of the simpler languages.

    The client is willing to pay for me to get Language Packs, but it sounds like I would have to work with all of the UI in Portuguese if I wanted to do that.

    I am delivering one Word form to hundreds of users. I don't think I could use pieterse's suggestion to also deliver a text file that the macro reads. At least not if I'm following his suggestion correctly.

    Bob
    Writing Consultant / Word Template Designer
    Words Connect

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    If all else fails, you could use a UserForm image control and display an image of impeccably formatted error text. Until you need to change the error. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    The VBE does not allow for entering such special characters directly, but you can write the texts in other programs, e.g. in an Access table or in an Excel list and read those into your VBA code. That does display properly AFAIK.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    I just tested. Characters other than the "usual" alphabetical ones display as ??? when I use a normal textbox, but on a userform's textbox they come through the same as I have them in my Excel cell (arabic as arabic, cyrillic as cyrillic, etc). So I guess you'd have to replace all your messageboxes with a userform (which should be simple). But I don't have an arabic version, so maybe with such a version the arabic characters would have appeared properly on messagebox too.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  8. #8
    2 Star Lounger
    Join Date
    May 2002
    Location
    Atlanta, Georgia, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    Thanks! I'll try that userform idea. That should be easy enough.

    In a couple of your messages, you've talked about "reading text into VBA code." Do you mean executing code that reads a text file at run time to load the translated string?

    Bob
    Writing Consultant / Word Template Designer
    Words Connect

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    Yes, I mean reading anything that may hold the text in its proper appearance. If a text file works; use a text file, if it needs to be a table in an Access file, Word, Excel, whatever, use that.
    So the reading bit depends on your storage type of course.
    You can easily use ADO to read from an Excel workbook without using Excel to open it, see:
    http://www.erlandsendata.no/english/index....envbadacwbdbado
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  10. #10
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    If the intent is to provide message box text for Word VBA code then it doesn't seem reasonable to have to use Excel or Access to store the message text. I guess it could be stored somewhere in the Word template, maybe as Autotext entries?

  11. #11
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    I thought about that too. It's just that I'm such and Excel addict <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  12. #12
    2 Star Lounger
    Join Date
    May 2002
    Location
    Atlanta, Georgia, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    For posterity, here's an update on how I resolved this problem. For the Western languages (Latin American and European), I was able to paste the translated text into the VB Editor and display error prompts using MsgBox. ("You entered weighted values that exceed 100%" and such). Chinese characters did not work in the VBE, so I displayed the prompts in a UserForm as Jefferson suggested. It was made more complicated because I needed to incorporate a variable in the message. The variable worked fine in languages with the MsgBox prompts. For the Chinese version, my quickest solution was to arrange the Chinese characters on the UserForm with a blank space, and I displayed the variable in another label over the blank spot.

    I was surprised that the VB Editor accepted and displayed Spanish, Portuguese and French characters, but it did. The tricky part in this project was that my form took some rating values, averaged them, and then rounded the decimal values up or down. Several of the languages use a different format for decimals (1,90 instead of 1.90), so I had to switch my Windows Regional and Language settings in Control Panel to get the right format for the fields in those languages. Parts of the form and code were more stringent about dealing with numbers in different formats. That took a bit of debugging.

    Anyway, thanks for your help. Too often, I come here for answers and never post back how things worked out. I am thankful for this resource!

    Bob
    Writing Consultant / Word Template Designer
    Words Connect

  13. #13
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    Hi Bob,

    Thanks for letting is know!

    NB: I would have worked with place holder text for variables and used the replace function:

    Label1.Caption=Replace(Label1.Caption,"_ARG1_",Wha teverVariableGoesHere)
    That means you don't get empty space which needs to be filled up by moving labels.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  14. #14
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    > I was able to paste the translated text into the VB Editor and display error prompts using MsgBox.

    A small warning with this technique.

    I had some very similar code in a VBA project, and I had all of my different language strings defined in a module with code like.
    <code>txtLang(16) = Array("High", "Hoch", "Alto", "Alto", "√Člev√© ", "Alto")</code>
    I then used a variable to select the correct word from each array.

    This code worked fine for most people, but gave compilation errors for users in Korea. It took quite a bit of investigation to discover that an é followed by a " was being interpreted as a valid 16 bit Korean character, resulting in an unterminated string! In this case just putting a space after the é caused it to compile correctly, but it certainly made me nervous of using anything other than standard US ASCII characters in VB.

    StuartR

  15. #15
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Different languages in MsgBox text? (Word 2003)

    >I don't think I could use pieterse's suggestion to also deliver a text file that the macro reads
    I used to do this regularly by storing the text as straight data in a module in the VB project. I prefaced each string with a single-quote (to make it a comment) and stripped the single-quote from the LHS before using the data.
    It's become a bit of a cottage industry.

    Two months ago I borrowed several suggestions from these forums and wrote some VBA that
    (1) obtained a JPEG image
    (2) translated it into ascii character values (see image)
    (3) built a little procedure that would regenerate the ascii sequence as a string, obviating the need for the quote-dequote procedure (see image)

    I could then write a user macro that would invoke the function and hence (a) grab the ascii sequence ( convert it (CHR$()) to a character string, © store the character string in a transient file with a JPG extension (d) import the JPG into a document and finally (e) delete the file.

    I'd consider storing data in a module in a runnable form.
    Attached Images Attached Images
    • File Type: jpg 1.JPG (70.4 KB, 4 views)

Page 1 of 2 12 LastLast

Posting Permissions

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