Alright, I've been researching this for the last few hours without much luck. Essentially, I've written some VBA for excel that does all the work I need but I would then like it to open an outlook template (OTF) file so that I can e-mail these attachments.
I have this code already in an outlook macro but it doesn't work when I copy/paste it in excel... the code is the following:
'Sub Open_Login_Logout()
'
'Set myItem = Application.CreateItemFromTemplate _
' ("M:\Reporting Templates\Metrics Shortcuts\Login Logout.oft")
' myItem.Display
'
' Set myAttachments = myItem.Attachments
' myAttachments.Add "M:\Reporting Templates\Custom Reports\Tony\HCLL02FEB08.xls", _
' olByValue, 1
' myAttachments.Add "M:\Reporting Templates\Custom Reports\Tony\NSDLL02FEB08.xls", _
' olByValue, 2
' myAttachments.Add "M:\Reporting Templates\Custom Reports\Tony\OSSDLL02FEB08.xls", _
' olByValue, 3
'
'End Sub
I've also found this site http://www.codeforexcelandoutlook.com/olAutomation.html that I thought would have solved my dileama with the following code:
Sub CreateMailInExcel()
Dim olApp As Outlook.Application
Dim Msg As Outlook.MailItem
Set olApp = New Outlook.Application
Set Msg = olApp.CreateItem(olMailItem)
Msg.Display
Set Msg = Nothing
Set olApp = Nothing
End Sub
BUT.... the code stops working when it fails to find Outlook.Application
I'm running Excel 2000 and Outlook 2003 (i know that's a dumb setup, but it's the only thing allowed at work).
Ideas?????????
I have this code already in an outlook macro but it doesn't work when I copy/paste it in excel... the code is the following:
'Sub Open_Login_Logout()
'
'Set myItem = Application.CreateItemFromTemplate _
' ("M:\Reporting Templates\Metrics Shortcuts\Login Logout.oft")
' myItem.Display
'
' Set myAttachments = myItem.Attachments
' myAttachments.Add "M:\Reporting Templates\Custom Reports\Tony\HCLL02FEB08.xls", _
' olByValue, 1
' myAttachments.Add "M:\Reporting Templates\Custom Reports\Tony\NSDLL02FEB08.xls", _
' olByValue, 2
' myAttachments.Add "M:\Reporting Templates\Custom Reports\Tony\OSSDLL02FEB08.xls", _
' olByValue, 3
'
'End Sub
I've also found this site http://www.codeforexcelandoutlook.com/olAutomation.html that I thought would have solved my dileama with the following code:
Sub CreateMailInExcel()
Dim olApp As Outlook.Application
Dim Msg As Outlook.MailItem
Set olApp = New Outlook.Application
Set Msg = olApp.CreateItem(olMailItem)
Msg.Display
Set Msg = Nothing
Set olApp = Nothing
End Sub
BUT.... the code stops working when it fails to find Outlook.Application
I'm running Excel 2000 and Outlook 2003 (i know that's a dumb setup, but it's the only thing allowed at work).
Ideas?????????