MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
Sub SendDocAsMail() Dim oOutlookApp As Outlook.Application Dim oItem As Outlook.MailItem On Error Resume Next 'Start Outlook if it isn't running Set oOutlookApp = GetObject(, "Outlook.Application") If Err <> 0 Then Set oOutlookApp = CreateObject("Outlook.Application") End If 'Create a new message Set oItem = oOutlookApp.CreateItem(olMailItem) oItem.Subject = "New or Transferred User" oItem.Recipients.Add "email@example.com" 'oItem.Recipients.Add "AnotherAddressIfYouWant.domain.com" 'Allow the user to write a short intro and put it at the top of the body 'Dim msgIntro As String 'msgIntro = InputBox("Write a short intro to put above your default " & _ "signature and current document." & vbCrLf & vbCrLf & _ "Press Cancel to create the mail without intro and " & _ "signature.", "Intro") 'Copies the first page ThisDocument.GoTo(wdGoToPage, 4).Select ThisDocument.Bookmarks("\page").Range.Copy 'Set the WordEditor Dim objInsp As Outlook.Inspector Dim wdEditor As Word.Document Set objInsp = oItem.GetInspector Set wdEditor = objInsp.WordEditor 'Write the intro if specified Dim i As Integer If msgIntro = IsNothing Then i = 1 'Comment the next line to leave your default signature below the document wdEditor.Content.Delete Else 'Write the intro above the signature wdEditor.Characters(1).InsertBefore (msgIntro) i = wdEditor.Characters.Count wdEditor.Characters(i).InlineShapes.AddHorizontalLineStandard wdEditor.Characters(i + 1).InsertParagraph i = i + 2 End If 'Place the current document under the intro and signature wdEditor.Characters(i).PasteAndFormat (wdFormatOriginalFormatting) 'Display the message oItem.Display 'Clean up Set oItem = Nothing Set oOutlookApp = Nothing Set objInsp = Nothing Set wdEditor = Nothing End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Outlook 2013 and random email addresses appearing in the autocomplete list.||6||17|
|VBA to Update status Column based on recent date||20||42|
|Troubleshooting a Macro for Doubleclick a Character in a Range Cell||4||14|
|In Excel 2007, how do I modify this formula so that the total number of question marks are printed out in a cell?||2||12|