#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default send button

I have created a form in excel. I would like to include a button that will
automatically email the form to a specific email address when pressed. I am
a new user and need step by step instructions.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 296
Default send button

On Wed, 2 Aug 2006 14:47:33 -0700, farhospurchase
wrote:

I have created a form in excel. I would like to include a button that will
automatically email the form to a specific email address when pressed. I am
a new user and need step by step instructions.


A method I use fairly frequently is outlined below.


If your button is an Activex control 'Command Button' right click on
it whilst in Design mode and add the code below between the

Private Sub CommandButton1_Click()
End Sub

lines of of code.


If your 'button' is say an object like a clip art graphic, or a
drawing object such as a rectangle etc. then you'll need to put the
same code in a VBA macro procedure. Hit ALT and F11 to go into the
Visual Basic environment.


In either case:
In the Project Explorer window, select your current workbook and then
from the Menu "Insert Module"

In the blank code window probably on the right, add a

Sub SendEmail
End Sub

procedure and again copy the code below between the Sub & End Sub
lines.

You'll need to

1.give a range name called "MyForm" to the area covered by your form
2. In the code below change the "stEmailName" text to the email name
of your recipient
3. Change the "stFolder" text to a suitable folder name

Close the Visual Basic environment when you've finished or ALT F11
bacl


Now when you click your button the form will first be copied and saved
as a file called "MyForm.xls". Then Outlook will open (if it's not
already open), and the file will be attached to the email.
Alter the text of the
..Subject and .Body to something meaningful as appropriate

Code to be pasted between a Sub...End Sub
-----------------
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim stEmailName As String
Dim olMyRecipient As Object
Dim stFolder As String

Set olApp = New Outlook.Application
stEmailName = "
stFolder = "c:\documents and settings\another\my documents"
Application.DisplayAlerts = False

Range("myform").Copy
Workbooks.Add
ActiveSheet.Paste
ActiveWorkbook.SaveAs Filename:="MyForm"
Set olMail = olApp.CreateItem(olMailItem)
Set olMyRecipient = olMail.Recipients.Add(stEmailName)

With olMail
.To = stEmailName
.Subject = "Your Subject"
.Body = "Body Text"
.Attachments.Add stFolder & "\Myform.xls"
End With

olMail.Send
----------

HTH

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SEND button in Excel Teddly Excel Worksheet Functions 1 May 24th 06 11:40 AM
Variable Text on a Button PaulW Excel Discussion (Misc queries) 1 May 10th 06 12:39 PM
XPSP4, Excel 02, custom button to SEND MESSAGE wont stay on toolb RGAnderson Excel Discussion (Misc queries) 0 September 19th 05 08:14 PM
How do I write a macro for a button to send user to a custom view? Hugnuffer Excel Discussion (Misc queries) 1 August 16th 05 06:34 PM
How do I setup a spin button in excel Andy K Excel Discussion (Misc queries) 1 November 26th 04 09:08 PM


All times are GMT +1. The time now is 11:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"