none
How to get the Language ID of Word dynamically. Cannot implicitly convert type 'Microsoft.Office.Core.MsoLanguageID' to 'Microsoft.Office.Interop.Word.WdLanguageID' RRS feed

  • Question

  • Hi,

    I want to get the language id of Word dynamically and assign it to Custom Dictionaries language id. I can do this when I know the language the Word is using Word.WdLanguageID.wdEnglishUS;. But how to get this dynamically. I tried as below but get a casting error. I can do this easily in VB6 but need a solution in c#

    C#

      oCustDict.LanguageSpecific = true;
      oCustDict.LanguageID = WordApp.Language;

    VB6 - Works

        Dim lCurrentLanguage As Long
        CurrentLanguage = WordApp.Language
        oCustDict.LanguageSpecific = True
        oCustDict.LanguageID = lCurrentLanguage



    Tuesday, July 21, 2015 5:27 PM

Answers

  • Hi BlueBangalore,

    The type of WordApp.Language is MsoLanguageID Enumeration, and the type of Word.WdLanguageID.wdEnglishUS is WdLanguageID Enumeration. I think there are two ways for you. If you want to get the wdEnglishUS to your Dictionary, you could use the code below:

    (Microsoft.Office.Interop.Word.WdLanguageID)word.Language

    If you want to get the WordApp.Language which is msoLanguageIDEnglishUS, you could reset the type of your Dictionary as “Microsoft.Office.Core.MsoLanguageID”.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by BlueBangalore Thursday, July 23, 2015 10:47 AM
    Wednesday, July 22, 2015 5:04 AM

All replies

  • Hi BlueBangalore,

    The type of WordApp.Language is MsoLanguageID Enumeration, and the type of Word.WdLanguageID.wdEnglishUS is WdLanguageID Enumeration. I think there are two ways for you. If you want to get the wdEnglishUS to your Dictionary, you could use the code below:

    (Microsoft.Office.Interop.Word.WdLanguageID)word.Language

    If you want to get the WordApp.Language which is msoLanguageIDEnglishUS, you could reset the type of your Dictionary as “Microsoft.Office.Core.MsoLanguageID”.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by BlueBangalore Thursday, July 23, 2015 10:47 AM
    Wednesday, July 22, 2015 5:04 AM
  • Excellent! Thanks Edward :)
    Thursday, July 23, 2015 10:47 AM