PDA

View Full Version : Change e-mail proofing language with VB .Net



mart.potter
05-27-2017, 12:48 AM
Currently, I have a VBA code to select e-mail content and change the proofing language. I use a reference to 'Microsoft Word 16.0 Object Library'.





Sub Lang(lngLanguage As Word.WdLanguageID)
' "Tools > References > Microsoft Word 16.0 Object Library" needs to be checked
Dim olkItem As Outlook.MailItem, _
wrdDoc As Word.Document, _
wrdSel As Word.Selection

Set olkItem = Outlook.ActiveInspector.CurrentItem
Set wrdDoc = olkItem.GetInspector.WordEditor
Set wrdSel = wrdDoc.Windows(1).Selection

wrdDoc.Bookmarks.Add Range:=wrdSel.Range, Name:="TheTemporarySpellerBookmark"

With wrdSel
.WholeStory
.LanguageID = lngLanguage
.Shrink
.GoTo What:=wdGoToBookmark, Name:="TheTemporarySpellerBookmark"
End With

wrdDoc.Bookmarks("TheTemporarySpellerBookmark").Delete
Set wrdSel = Nothing
Set wrdDoc = Nothing
Set olkItem = Nothing
End Sub
Sub AllinENG()
Lang (wdEnglishUK)
End Sub


How to convert it to VB .NET? I guess I need to 'Imports Microsoft.Office.Interop.Word' but what next? I somehow need to use WordEditor but I haven't figured out the correct syntax for that.