![]() |
|
#1
|
|||
|
|||
|
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
|
|
#2
|
||||
|
||||
|
Code:
ActiveWindow.EnvelopeVisible = True 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 |
|
#3
|
|||
|
|||
|
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 |
|
| Thread Tools | |
| Display Modes | |
|
|
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 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 |