Here I am going to put the script which is actually run by a macro in Excel sheet which will put the excel sheet data into the Microsoft outlook.
Sub AddButton()
Set btn = ActiveSheet.Buttons.Add(0, 90, 100, 25)
'ActiveSheet.Buttons.Add(x,y,length,width)
btn.OnAction = "AddAppointment"
btn.Characters.Text = "Run Outlook"End Sub
Private Sub AddAppointment()
Dim objOL 'As Outlook.Application
Dim objAppt 'As Outlook.AppointmentItem
Const olAppointmentItem = 1
Const olMeeting = 1
Const olFree = 0
MySubject = Worksheets("Data").Range("A2").Value
MyStartDatetime = Worksheets("Data").Range("A3").Value
MyDuration = Worksheets("Data").Range("A4").Value
MyLocation = Worksheets("Data").Range("A5").Value
MyBody = Worksheets("Data").Range("A6").Value
MyDelay = Worksheets("Data").Range("A7").Value
Set objOL = CreateObject("Outlook.Application")
Set objAppt = objOL.CreateItem(olAppointmentItem)
objAppt.Subject = MySubject
objAppt.Start = MyStartDatetime
objAppt.Duration = MyDuration
objAppt.Location = MyLocation
objAppt.Body = MyBody
objAppt.ReminderMinutesBeforeStart = MyDelay
objAppt.BusyStatus = olFree
objAppt.Save
Set objAppt = Nothing
Set objOL = Nothing
End Sub
No comments:
Post a Comment