Adding an attachment to an Outlook calendar invite via Macro

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
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,223,244
Messages
6,170,976
Members
452,372
Latest member
Natalie18

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top