adding meeting to outlook run time error 462

sspreyer

Registered User.
Local time
Today, 03:41
Joined
Nov 18, 2013
Messages
251
hi ,
all

i have some code that creates appointment that i can send to collegues
when i run the code first time it work all ok but the second time i run it i get a run time error see pic below

but i dont get any error's if i leave outlook open have also try the code on 2 pc's but stiill same problem

1392336756_tmp_run_time_error[1].jpg

here my code:

Code:
 Shell ("Outlook.exe")
 
Dim outMail As Object
Set outMail = Outlook.CreateItem(olAppointmentItem)
outMail.Recipients.Add (Me.txtsupervisor)
outMail.RequiredAttendees = attendees ' name of attendees
outMail.Subject = Me.txtsubject ' subject of meeting
outMail.Location = Me.cbolocation ' location of meeting
outMail.MeetingStatus = olMeeting 'what type of appointment it is
outMail.start = Me.txtdatedue & " " & "10:00 AM" '[Date] & " " & [Time] 'fill in columns with date and time variables (or just put in default time such as "09:00")
outMail.Body = Me.txtbody 'text in main body
outMail.ReminderMinutesBeforeStart = 20

outMail.Display

can someone please point me in the right direction

thanks in advance

shane
 
You first need to create an Object for Outlook Application..
Code:
[COLOR=Red][B]Dim outApp As Object[/B][/COLOR]
Dim outMail As Object

[COLOR=Red][B]Set outApp = CreateObject("Outlook.Application")[/B][/COLOR]
Set outMail = outApp.CreateItem(olAppointmentItem)

outMail.Recipients.Add (Me.txtsupervisor)
outMail.RequiredAttendees = attendees [COLOR=Green]' name of attendees[/COLOR]
outMail.Subject = Me.txtsubject [COLOR=Green]' subject of meeting[/COLOR]
outMail.Location = Me.cbolocation[COLOR=Green] ' location of meeting[/COLOR]
outMail.MeetingStatus = olMeeting [COLOR=Green]'what type of appointment it is[/COLOR]
outMail.start = Me.txtdatedue & " " & "10:00 AM" '[Date] & " " & [Time] 'fill in columns with date and time variables (or just put in default time such as "09:00")
outMail.Body = Me.txtbody 'text in main body
outMail.ReminderMinutesBeforeStart = 20
outMail.Display
Also use a proper Error handler ! http://www.cpearson.com/Excel/ErrorHandling.htm
 
You first need to create an Object for Outlook Application..
Code:
[COLOR=red][B]Dim outApp As Object[/B][/COLOR]
Dim outMail As Object

[COLOR=red][B]Set outApp = CreateObject("Outlook.Application")[/B][/COLOR]
Set outMail = outApp.CreateItem(olAppointmentItem)
hi paul thanks I had tried the code above before posting on here I couldn't get it to work but for some reason I copied yours and it works you must have the magic touch

thanks again Paul you legend !!!

p.s thanks for error handler tip

shane
 
Last edited:

Users who are viewing this thread

Back
Top Bottom