Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Command Button - Macro to print to pdf, then send pdf to email. | Excel Discussion (Misc queries) | |||
Button to send current excel workbook by email | Excel Discussion (Misc queries) | |||
Excel email mode send button?? | Excel Discussion (Misc queries) | |||
Can I send a doc to group of email addresses via a macro button? | Excel Discussion (Misc queries) | |||
Form to send by Email | Excel Discussion (Misc queries) |