Skip to content

Instantly share code, notes, and snippets.

@stevedep
Created January 15, 2023 08:51
Show Gist options
  • Save stevedep/b0e876b49b78e99b27167707e965324f to your computer and use it in GitHub Desktop.
Save stevedep/b0e876b49b78e99b27167707e965324f to your computer and use it in GitHub Desktop.
Sub openmail()
Set oOutlook = GetObject(, "Outlook.Application")
Set NS = oOutlook.GetNamespace("MAPI")
NS.Logon
Set msg = NS.GetItemFromID(ActiveCell.Value)
msg.display
Set objInsp = msg.GetInspector
Set objDoc = objInsp.WordEditor
Application.Wait (Now + TimeValue("0:00:02"))
Set myRange = objDoc.Range(Start:=ActiveCell.Offset(0, 5), End:=ActiveCell.Offset(0, 6))
myRange.Select
Set oOutlook = Nothing
Set NS = Nothing
Set msg = Nothing
Set objInsp = Nothing
Set objDoc = Nothing
Set objsel = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment