63570

Outlook VBA Set language of selection

I'm try to create a macro to set the language of the selection in an outlook email.

I have little experience in VBA scripting.

I copied the Macro I recorded in Word into my Macro-Table for Outlook (or project, or module, I'm not sure how it is named)

Sub SelectionEnglish() Selection.LanguageID = wdEnglishUS Selection.NoProofing = False Application.CheckLanguage = True End Sub

This doesn't work because the Selection object is not available. But I saw another question (which I can't find anymore) where the macro author had a way to use the word-editor inside the outlook macro.

Answer1:

Yes, a text selection in the email body – tjb 21 mins ago

Try this (To be run from Outlook VBA) Tried and tested on a newly created email. This code shows how to work with the Selection Object

Sub Sample() Dim oMailItm As Object, oInsp As Object, oMailEd As Object Dim oWord As Object, rng As Object Set oInsp = Application.ActiveInspector If oInsp.CurrentItem.Class = olMail Then Set oMailItm = oInsp.CurrentItem If oInsp.EditorType = olEditorWord Then Set oMailEd = oMailItm.GetInspector.WordEditor Set oWord = oMailEd.Application '~~> Set your selection object here Set rng = oWord.Selection '~~> This is to check if we are getting the selection object '~~> You may comment this or remove it later. MsgBox rng.Text With rng ' '~~> Rest of the code ' End With End If End If Set rng = Nothing Set oWord = Nothing Set oMailEd = Nothing Set oMailItm = Nothing Set oMailItm = oInsp End Sub

Recommend

  • Angularjs how to update view after a REST (delete) operation?
  • How to limit people access to my EC2 with their public key
  • Sequential reading of a json format
  • Change Activity Class to Fragment
  • Localization: How to map culture info to a script name or Unicode character range?
  • Multiple arguments for a PHP function
  • How to edit text file data with c++
  • How can I setting datasource in Spring application
  • Function that retrieves element from HList (while preserving its type)
  • Performant cartesian product (CROSS JOIN) with pandas
  • Why does [[ -eq ]] show non-numerical strings as equal in Bash?
  • Hide option in select based on other select value
  • How to install the guess_language package in Python
  • Is there a way to do multiline editing a-la Visual Studio in Sublime?
  • javascript regex to get url from string containing script tag
  • call js confirm from code behind
  • Reload UIPickerView crash [duplicate]
  • ValueError: 0 is not in list when running this code
  • UpdateException when using SQL Server Compact with Entity Framework
  • Multiple values RewriteMap prg
  • Scheme: overload built-in procedures, general overloading
  • str_replace keys in multidimensional array PHP
  • I have accidentally uninstalled jack server while building Android AOSP
  • Error: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
  • allocating memory to an array of string
  • What does “t” refer to in this SQL?
  • CERN ROOT exporting data to plain text
  • Django simple Captcha “No module named fields” error
  • Why does access(2) check for real and not effective UID?
  • Spring Data JPA custom method causing PropertyReferenceException
  • C# - Serializing and deserializing static member
  • Sending data from AppleScript to FileMaker records
  • How to include full .NET prerequisite for Wix Burn installer
  • How to stop GridView from loading again when I press back button?
  • Bitwise OR returns boolean when one of operands is nil
  • Is it possible to post an object from jquery to bottle.py?
  • sending mail using smtp is too slow
  • Recursive/Hierarchical Query Using Postgres
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs