View Full Version : Macro code to send a spreadsheet by eMail


Kellie Turnbull
10-27-2006, 08:29 AM
Hi, I was wondering if anyone could help me?

I would like to create a macro which I can attach to a command button in an excel spreadsheet that will eMail the same spreadsheet to a pre-defined eMail address.

I have tried to record the macro using the eMail option under the File menu (File - Send To - Mail Recipient as attachment) but it doesn't seem to work. I am assuming that it's because the eMail form is not part of Excel.

Can anyone send me some code that I can attach to the click command in VB? I can play around with it if it's not completely right.

Many thanks in advance.

Kellie

apr pillai
10-27-2006, 01:49 PM
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 28/10/2006 by user
'
' Keyboard Shortcut: Ctrl+j
'
Application.Dialogs(xlDialogSendMail).Show
End Sub

Above Macro is recorded to run when Ctrl+j keyboard shortcut is used on the Active Worksheet, Full Excel File will go as attachment not just the current worksheet. Outlook must be configured with pop & smtp etc.

First you record a small Macro for some action (anything), in the dilogbox that appear enter a character (say j ) in the text box after the Ctrl+ label so that you can use that shortcut key to run the macro. After recording the macro delete the recorded text and copy

Application.Dialogs(xlDialogSendMail).Show

into the Macro and try with the Keyboard Shortcut to run it.