Programmatically set the language of a word document using Word's object modal in Visual Basic 2005

© copyright 19.Oct.2009 by Paul Bradley filed under Visual Basic


I am currently developing a document management system, using Word as the editor which is embedded into a picture box on a form, so that I have complete control over it's operation / integration. The system uses RTF as the document format, which gets stored into a database. I have no problem setting the Language for the file initially, as I send the RTF code deflang2057 to set the default language to English UK.

However, when the saved RTF is retrieved from the database, Word would always switch the Language to English US, so I have to force the Language back to English UK by changing the language ID for the active document using the following syntax :-

Public WithEvents ObjWord As Word.Application

ObjWord = New Word.ApplicationClass

ObjWord.Visible = True
ObjWord.Documents.Open("c:\body.rtf")

ObjWord.ActiveDocument.Range.LanguageID = Word.WdLanguageID.wdEnglishUK

 


If you have found this article helpful or useful please consider linking to it, emailing it to friends, or share it with others using social sites like del.icio.us, Stumble Upon or Twitter.

Paul Bradley

About the Author
Paul Bradley is a VB.NET software developer living and working in Cumbria. He has over 20 years programming experience. He also produces e-learning videos at Linux by Example

Other Popular Articles

Categories & Topics

Home · Apache · JavaScript · Perl · PDF · PHP · MySQL · MSSQL · TAR · Ubuntu Linux · Video · Visual Basic

Browse the complete article history, and if you like what you see; consider subscribing to the rss feed.