none
Translate Word document English to German without changing document format using vb.net RRS feed

  • Question

  • Hi,

    I have developed one application which out put is MS word document.The document generated in English language.and I want one copy of same document in German language without changing format of word document.Is any possible way of doing change language in Vb.NET?

    Tuesday, May 26, 2015 6:55 AM

Answers

  • Hi GC_04,

    >> I want one copy of same document in German language without changing format of word document.Is any possible way of doing change language in Vb.NET?<<

    Based on mu understanding, it is hard to achieve the goal using Word object modle to automate the Word application.

    However, it is possible to use Open XML to achieve the goal. For example, we can get the all the text from Word document using Open XML via Text class and translate it by yourself and replace the text. And here is a demo sample for your reference:

      string filePath = @"C:\Hello Word.docx";
                using (WordprocessingDocument wordDocument =
                    WordprocessingDocument.Open(filePath,true))
                {
                                   MainDocumentPart mainPart = wordDocument.MainDocumentPart;
    
                                   foreach (Text text in mainPart.Document.Body.Descendants<Text>())
                    {
                        text.Text = TranslateText(text.Text);
                    }
                }

    In addition, here is an helpful article about text mastering in Open XML:
    Mastering Text in Open XML WordprocessingML Documents

    If you have problem translate the demo code into VB.Net, please feel free to let me know. 

    Regards & Fei


    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.

    Wednesday, May 27, 2015 5:31 AM
    Moderator

All replies

  • Hi,

    I have developed one application which out put is MS word document.The document generated in English language.and I want one copy of same document in German language without changing format of word document.Is any possible way of doing change language in Vb.NET?

    • Merged by Youjun Tang Tuesday, June 2, 2015 9:28 AM duplicate post
    Tuesday, May 26, 2015 6:56 AM
  • The right forum for this question is Word for Developers, a moderator will move it for you.

    Fouad Roumieh

    • Proposed as answer by Cor Ligthert Tuesday, May 26, 2015 3:07 PM
    Tuesday, May 26, 2015 7:11 AM
  • Fouad is giving giving the the correct reply.

    But for you start asking that try, try to understand what a language is. 

    Simply translate an English Text in German using Google translate and than you will see a Indo-European Language does not only exist from from characters and words, it is the way it is written which makes the language and that influences the format. (German uses for instance very much grammatical cases, most English speakers don't even know what it is).


    Success
    Cor


    Tuesday, May 26, 2015 3:07 PM
  • Hi GC_04,

    >> I want one copy of same document in German language without changing format of word document.Is any possible way of doing change language in Vb.NET?<<

    Based on mu understanding, it is hard to achieve the goal using Word object modle to automate the Word application.

    However, it is possible to use Open XML to achieve the goal. For example, we can get the all the text from Word document using Open XML via Text class and translate it by yourself and replace the text. And here is a demo sample for your reference:

      string filePath = @"C:\Hello Word.docx";
                using (WordprocessingDocument wordDocument =
                    WordprocessingDocument.Open(filePath,true))
                {
                                   MainDocumentPart mainPart = wordDocument.MainDocumentPart;
    
                                   foreach (Text text in mainPart.Document.Body.Descendants<Text>())
                    {
                        text.Text = TranslateText(text.Text);
                    }
                }

    In addition, here is an helpful article about text mastering in Open XML:
    Mastering Text in Open XML WordprocessingML Documents

    If you have problem translate the demo code into VB.Net, please feel free to let me know. 

    Regards & Fei


    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.

    Wednesday, May 27, 2015 5:31 AM
    Moderator