fallinup00
New Member
- Joined
- Jan 16, 2013
- Messages
- 8
Hi,
I have a macro that is run out of Excel and takes data held in each row and creates an MS Outlook calendar invite from it. However, I cannot figure out how to add an attachment to the body of the Outlook invite via this macro.
I have tried recording the addition of an attachment displayed as an icon to an Excel spreadsheet and editing that for the addition to the body of the invite, but am recieving an error message after editing it for Outlook.
Here is the recorded code to embed a file into Excel:
ActiveSheet.OLEObjects.Add(Filename:= _
"C:\Users\amclellan\Documents\Template Documents\Blank Roster\Roster Template Virtual Events.xls" _
, Link:=False, DisplayAsIcon:=True, IconFileName:= _
"C:\windows\Installer\{90120000-0011-0000-0000-0000000FF1CE}\xlicons.exe", _
IconIndex:=0, IconLabel:= _
"C:\Users\amclellan\Documents\Template Documents\Blank Roster\Roster Template Virtual Events.xls" _
).Select
Here is the error I recieve after editing the code and trying to run it for Outlook:
Run-time error '424':
Object required
Here is the snippet of the code that adds the information to the Outlook invite. the second .Body which I've left left justified is what I'm trying to use to add the file.
Does anyone have any thoughts?
Cheers,
-A
Set OLAppointment = olApp.CreateItem(olAppointmentItem)
With OLAppointment
'.Recipients.Add Cells(r, 10).Value
.requiredAttendees = Cells(r, 12).Value
'.Organizer = Cells(r, 12).Value
.Subject = Cells(r, 13).Value
.Start = Cells(r, 4).Value
.Duration = Cells(r, 5).Value * 60
.ReminderMinutesBeforeStart = 15
.Location = Cells(r, 7)
.Body = Cells(r, 14).Value
.Body.OLEObjects.Add(Filename:= _
"C:\Users\amclellan\Documents\Template Documents\Blank Roster\Roster Template Virtual Events.xls" _
, Link:=False, DisplayAsIcon:=True, IconFileName:= _
"C:\windows\Installer\{90120000-0011-0000-0000-0000000FF1CE}\xlicons.exe", _
IconIndex:=0, IconLabel:= _
"C:\Users\amclellan\Documents\Template Documents\Blank Roster\Roster Template Virtual Events.xls" _
).Select
.categories = Cells(r, 6)
.alldayevent = False
.Recipients.resolveAll
.Save
'.Send
End With
I have a macro that is run out of Excel and takes data held in each row and creates an MS Outlook calendar invite from it. However, I cannot figure out how to add an attachment to the body of the Outlook invite via this macro.
I have tried recording the addition of an attachment displayed as an icon to an Excel spreadsheet and editing that for the addition to the body of the invite, but am recieving an error message after editing it for Outlook.
Here is the recorded code to embed a file into Excel:
ActiveSheet.OLEObjects.Add(Filename:= _
"C:\Users\amclellan\Documents\Template Documents\Blank Roster\Roster Template Virtual Events.xls" _
, Link:=False, DisplayAsIcon:=True, IconFileName:= _
"C:\windows\Installer\{90120000-0011-0000-0000-0000000FF1CE}\xlicons.exe", _
IconIndex:=0, IconLabel:= _
"C:\Users\amclellan\Documents\Template Documents\Blank Roster\Roster Template Virtual Events.xls" _
).Select
Here is the error I recieve after editing the code and trying to run it for Outlook:
Run-time error '424':
Object required
Here is the snippet of the code that adds the information to the Outlook invite. the second .Body which I've left left justified is what I'm trying to use to add the file.
Does anyone have any thoughts?
Cheers,
-A
Set OLAppointment = olApp.CreateItem(olAppointmentItem)
With OLAppointment
'.Recipients.Add Cells(r, 10).Value
.requiredAttendees = Cells(r, 12).Value
'.Organizer = Cells(r, 12).Value
.Subject = Cells(r, 13).Value
.Start = Cells(r, 4).Value
.Duration = Cells(r, 5).Value * 60
.ReminderMinutesBeforeStart = 15
.Location = Cells(r, 7)
.Body = Cells(r, 14).Value
.Body.OLEObjects.Add(Filename:= _
"C:\Users\amclellan\Documents\Template Documents\Blank Roster\Roster Template Virtual Events.xls" _
, Link:=False, DisplayAsIcon:=True, IconFileName:= _
"C:\windows\Installer\{90120000-0011-0000-0000-0000000FF1CE}\xlicons.exe", _
IconIndex:=0, IconLabel:= _
"C:\Users\amclellan\Documents\Template Documents\Blank Roster\Roster Template Virtual Events.xls" _
).Select
.categories = Cells(r, 6)
.alldayevent = False
.Recipients.resolveAll
.Save
'.Send
End With