Quizzes & Puzzles6 mins ago
VBA Code
3 Answers
Can anyone tell me the VBA code if there is one for Excel for when you press a button the file automatically emails a notification to tell you someone has pressed the button?
Answers
Best Answer
No best answer has yet been selected by Coldfusion. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.'Right-click the Menu Bar, choose 'Forms', drag and drop the Command Button from the 'Forms' toolbar onto the right location of your Excel form (or worksheet), and when the 'Assign Macro' midalog appears, click 'New'. You'll now see the VB Editor, with an empty macro, like this:
Sub Button1_Click()
End Sub
Just put the following code in between the opening line (Sub xxx()) and the end line(End Sub):
ThisWorkbook.SendMail "[email protected]"
You can use this modified macro, which checks if the mail system is a MAPI system, and executes it in another way is it is not, or outputs a message box, "No Mail System" if there is none.
Select Case Application.MailSystem
Case xlMAPI
ThisWorkbook.SendMail Recipients:=""
Case xlNoMailSystem
MsgBox "no mail client"
Case Else
Application.CommandBars("worksheet menu bar") _
.Controls("File").Controls("Send To").Controls("Mail Recipient...").Execute
End Select
Or you could try that