Hi,
I can't work out what the error is on this vba code. It keeps getting to .SaveAs but getting a Run-time error '287'. Does anyone have any idea?
Thanks,
I can't work out what the error is on this vba code. It keeps getting to .SaveAs but getting a Run-time error '287'. Does anyone have any idea?
Code:
Function MailClient()
Const Key As String = "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\"
Dim ws As Object
On Error Resume Next
Set ws = CreateObject("WScript.Shell")
MailClient = ws.RegRead(Key)
End Function
Sub SetAppt()
Dim olApp As Object
Dim olApt As Object
Set olApp = CreateObject("Outlook.Application")
Set olApt = olApp.CreateItem(1)
With olApt
.Start = Range("B4").Value + TimeValue("09:00:00")
.End = .Start + TimeValue("00:30:00")
.Subject = Range("A4").Value
.Location = Range("E4").Value
.Body = "insert guidance text here"
.BusyStatus = olBusy
.ReminderMinutesBeforeStart = 40
.ReminderSet = True
.Display
.SaveAs "C:\temp\day1.ics"
'Use Close to retain the new appointment within the Outlook Calendar, or Delete to delete it.
'Both options keep the just-created .ics file
.Close False
'.Delete
End With
Set olApt = Nothing
Set olApp = Nothing
End Sub
Thanks,