Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default cmd button, send form via email

I have a protected Exel form which works very nicely. We
have put it on our intranet, and would like to have a
command button at the bottom of the form to send the
filled out form to a specific email address. I don't know
if it is a series of steps such as programatically doing a
file save as.. and opening a email putting a subject line
in the and sending, or if it is as easy as
incorporating a mailto: . I'm just
guessing! It would be nice to display a dialog box at the
end that says "Form has been submitted, to save a copy
locally you must use the File, Save As... command" and an
OK button.

Could someone please send me a code snippet, which I image
would be put in the command button click event.

Thank you in advance
God bless you


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default cmd button, send form via email

Andy, you cannot send the form directly but can either copy the form values
from the form, or if they are stored in a worksheet, from the worksheet.
These can be written into the body of an email or the whole workbook
attached to an email.

The following provides a template that you might wish to adapt. The .body
shows how to get values from the worksheet, but these could also be the
values from the form controls. The Attachment.Add can be also used as
shown, use the olByValue to attach a copy of the workbook or olByReference
if you would like it to be a link. The .To (add CC, BCC) address can be
formed from any string or values from a userform or worksheet cell, thus you
can adapt the email recipient accordingly. HTH.

In the VBA editor use the Tools-References option to select the Microsoft
Outlook Library

Sub MailSomeData()
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "A title "
.Body = "This is an automated email to advise that the data is
attached to this email." & _
"First data value:" &
Worksheets.("Sheet1").Range("A1").Value & vbcrlf & _
"Next data value:" &
Worksheets.("Sheet1").Range("A2").Value
.Attachments.Add (C:\workbook.xls"), olByValue
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Cheers
Nigel


"andy" wrote in message
...
I have a protected Exel form which works very nicely. We
have put it on our intranet, and would like to have a
command button at the bottom of the form to send the
filled out form to a specific email address. I don't know
if it is a series of steps such as programatically doing a
file save as.. and opening a email putting a subject line
in the and sending, or if it is as easy as
incorporating a mailto: . I'm just
guessing! It would be nice to display a dialog box at the
end that says "Form has been submitted, to save a copy
locally you must use the File, Save As... command" and an
OK button.

Could someone please send me a code snippet, which I image
would be put in the command button click event.

Thank you in advance
God bless you






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
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
Command Button - Macro to print to pdf, then send pdf to email. Tdahlman Excel Discussion (Misc queries) 2 May 1st 23 11:44 AM
Button to send current excel workbook by email Chris O Excel Discussion (Misc queries) 1 March 23rd 09 10:57 PM
Excel email mode send button?? JerryCic Excel Discussion (Misc queries) 1 August 7th 07 09:25 PM
Can I send a doc to group of email addresses via a macro button? Richard F Excel Discussion (Misc queries) 6 February 5th 07 09:59 AM
Form to send by Email Cloudburst99 Excel Discussion (Misc queries) 0 April 21st 05 03:00 PM


All times are GMT +1. The time now is 07:06 PM.

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"