excel vba linking outlook
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft VBA Training and help » Excel VBA Linking to OUTLOOK Email

Excel VBA Linking to OUTLOOK Email

resolvedResolved · Urgent Priority · Version 2010

replyReply Thu 29 Sep 2011, 09:30Delegate Shamin said...

Shamin has attended:
Excel VBA Intro Intermediate course
Excel VBA Advanced course

Excel VBA Linking to OUTLOOK Email

Hi Anthony,

Can I have some information related to Ecal VBA linking to Outlook email?

Attended course Excel VBA Advanced in Bloomsbury in Limehouse.

Regards
Shamim Akhtra

For upcoming training course dates see: Pricing & availability

replyReply Fri 30 Sep 2011, 07:26Trainer Anthony said...

RE: Excel VBA Linking to OUTLOOK Email

Hi Shamin, thanks for your query. This subroutine contains the nuts and bolts of what you'll need:

*******************

Sub EmailWithOutlook()
'Variable declaration
Dim oApp As Object, _
oMail As Object, _
WB As Workbook, _
FileName As String

'Turn off screen updating
Application.ScreenUpdating = False

'Make a copy of the active sheet and save it to
'a temporary file
ActiveSheet.Copy
Set WB = ActiveWorkbook
FileName = "Temp.xls"
On Error Resume Next
Kill "C:\" & FileName
On Error GoTo 0
WB.SaveAs FileName:="C:\" & FileName

'Create and show the outlook mail item
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
'Uncomment the line below to hard code a recipient
'.To = "someone@somedomain.com"
'Uncomment the line below to hard code a subject
'.Subject = "Look at my workbook!"
.Attachments.Add WB.FullName
.Display
End With

'Delete the temporary file
WB.ChangeFileAccess Mode:=xlReadOnly
Kill WB.FullName
WB.Close SaveChanges:=False

'Restore screen updating and release Outlook
Application.ScreenUpdating = True
Set oMail = Nothing
Set oApp = Nothing
End Sub

*******************

Hope this helps,

Anthony

replyReply Fri 30 Sep 2011, 10:41Delegate Shamin said...

RE: Excel VBA Linking to OUTLOOK Email

Hi,

Thanks for the information, and prompt response.

Kind regards
Shamim

 

Please browse our web site to find out more about
vba excel 2007 course and other Microsoft training courses.

Vba tip:

Stuck in a Code Loop

If you ever get stuck in an infinite code loop when programing in VBA use

CTRL+BREAK

to exit the procedure

View all VBA hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard