Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-18-2016, 09:35 PM
subfuze subfuze is offline Send Email Recipient Macro Windows 7 32bit Send Email Recipient Macro Office 2016
Novice
Send Email Recipient Macro
 
Join Date: Jun 2016
Posts: 2
subfuze is on a distinguished road
Default Send Email Recipient Macro


Guys I am creating a form, along the bottom of it I want a link or button which will drop down the 'send email recipient' from the Word Ribbon. Any assistance would be appreciated
Reply With Quote
  #2  
Old 06-19-2016, 12:54 AM
gmayor's Avatar
gmayor gmayor is offline Send Email Recipient Macro Windows 10 Send Email Recipient Macro Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,105
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 of
Default

Code:
ActiveWindow.EnvelopeVisible = True
will dropdown the e-mail message envelope, but I don't think this will be of much help to the users of your form, for whom I guess that the button is meant to return the form to you?

In which case call the macro 'Send_As_HTML_EMail' from your button

Code:
Option Explicit

Sub Send_As_HTML_EMail()
Dim bStarted As Boolean
Dim olApp As Object
Dim oItem As Object
Dim orng As Range
Dim objdoc As Object
Dim objSel As Selection
Const sRecipient As String = "someone@somewhere.com"    'The address to which the form is to be sent
Const sSubject As String = "The message subject"

    If IsOutlook = False Then
        MsgBox "It appears that you do not have Outlook available to return the form." & vbCr & vbCr & _
               "Please save and attach the completed form to a new e-mail message using your normal e-mail application and return it to " & _
               sRecipient, vbCritical, "Outlook not available"
        GoTo lbl_Exit
    End If
    On Error Resume Next
    Set orng = ActiveDocument.Range
    orng.Copy
    'Get Outlook if it's running
    Set olApp = GetObject(, "Outlook.Application")
    If Err <> 0 Then
        'Outlook wasn't running, start it from code
        Set olApp = CreateObject("Outlook.Application")
        bStarted = True
    End If
    'Create a new mailitem
    Set oItem = olApp.CreateItem(0)
    With oItem
        .BodyFormat = 2
        .Display
        Set objdoc = .GetInspector.WordEditor
        Set objSel = objdoc.Windows(1).Selection
        objSel.Paste
        .to = sRecipient
        .Subject = sSubject
        .Send
    End With
    If bStarted Then
        'If we started Outlook from code, then close it
        olApp.Quit
    End If
    'Clean up
    Set oItem = Nothing
    Set olApp = Nothing
lbl_Exit:
    Exit Sub
End Sub

Public Function IsOutlook() As Boolean
    On Error Resume Next
    IsOutlook = (Not CreateObject("Outlook.Application") Is Nothing)
lbl_Exit:
    Exit Function
End Function
__________________
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
  #3  
Old 06-19-2016, 06:05 PM
subfuze subfuze is offline Send Email Recipient Macro Windows 7 32bit Send Email Recipient Macro Office 2016
Novice
Send Email Recipient Macro
 
Join Date: Jun 2016
Posts: 2
subfuze is on a distinguished road
Default

Just to finalise this for those interested. I followed gmayor's advice (thanks gmayor) in relation to:

ActiveWindow.EnvelopeVisible = True

I created the above macro. Then to insert I used the field function (Insert -->Quick Parts --> Field

In field names select Macrobutton then select the macro you created (with some display text) click ok. Double click on the text and the drop down appears.

FYI I only need the drop down to appear as different users will be sending the email to different email recipients dependant on the intial email sent to them.

I appreciate your assistance
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook macro to check a value of a cell in an attachment and send an email based on that value ketangarg86 Outlook 13 03-25-2015 07:11 AM
Send Email Recipient Macro send to Mail recipient romanticbiro Outlook 1 07-30-2014 03:51 AM
Macro to send from non-default email address k.n. Mail Merge 5 12-03-2013 03:22 AM
Macro to send document in email AnneN Word VBA 1 02-05-2013 08:08 PM
Macro to export email to text file on send depending on category Joe Patrick Outlook 0 10-19-2012 06:20 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft