View Single Post
 
Old 04-16-2015, 02:18 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If you are running the userform in Outlook, there is no need to create an Outlook application. You already have one and you are using it.

Code:
Option Explicit

Private Sub CommandButton1_Click()
    If Me.OptionButton1.Value = True Then
        Me.Hide
        MsgBox "OptionButton 1 was selected"
        Call Email672200        ' Module 2
    End If
    If Me.OptionButton2 Then
    Me.Hide
        MsgBox "OptionButton 2 was selected"
    End If
    Unload Me
End Sub
Sub Email672200()
Dim Outmail As Outlook.MailItem
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
    Set Outmail = CreateItem(olMailItem)
    With Outmail
        .BodyFormat = olFormatHTML
        .To = "672200"
        .CC = "672200 CC"
        .BCC = ""
        '.Attachments.Add ""
        .Display
        .Subject = "672200 - Escrow Shortage Account"
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set oRng = wdDoc.Range(0, 0)
        oRng.Text = "Hello Everyone"
        
    End With
    On Error GoTo 0
    Set Outmail = Nothing
End Sub
Private Sub CommandButton2_Click()
    Unload Me
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote