I've been working on the below code for days, hopefully the end product will do 2 things.
Send an email to a team organizer with details from the spreadsheet. Send an outlook appointment to the desk assessor with the appointment details.
I get an error message saying:
Compile Error:
End if without block if
Sub ACarr_Step2()
Dim iRet As Integer
Dim strPrompt As String
Dim strTitle As String
' Promt
strPrompt = "Have you checked if Joe Bloggs is available?"
' Dialog's Title
strTitle = "Availability Confirmation"
'Display MessageBox
iRet = MsgBox(strPrompt, vbYesNo, strTitle)
' Check pressed button
If iRet = vbNo Then
MsgBox "Please check Availability with Joe Bloggs"
Else
Dim OutApp As Object
Dim OutMail As Object
assessor = Sheets("ACarr").Range("AB5").Text
clerk = Sheets("ACarr").Range("AB1").Text
team = Sheets("ACarr").Range("AB2").Text
datee = Sheets("ACarr").Range("AB3").Text
timeslot = Sheets("ACarr").Range("AB4").Text
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "Team.organizer@company.co.uk"
.CC = ""
.BCC = ""
.Subject = "DSE Assessment Booking"
.Body = "Hi there," & vbNewLine & vbNewLine & "Could you please arrange for the agents below to be rota'd off to complete a Desk Assessment." & vbNewLine & vbNewLine & "Assessor: " & assessor & vbNewLine & "Staff Member : " & clerk & vbNewLine & "Team: " & team & vbNewLine & "Date: " & datee & vbNewLine & "Time Slot: " & timeslot & vbNewLine & vbNewLine & "Thank You"
.send
' Create the Outlook session
Set myoutlook = CreateObject("Outlook.Application")
' Create the AppointmentItem
Set myapt = myoutlook.CreateItem(olAppointmentItem) ' Set the appointment properties
With myapt
.Subject = "DSE Assessment Booking"
.Location = Sheets("ACarr").Range("AB2").Text
.Start = Sheets("ACarr").Range("AB4").Text
.Duration = 30
.Recipients = "Desk.Assessor@Company.co.uk"
.MeetingStatus = olMeeting
' not necessary if recipients are email addresses
'myapt.Recipients.ResolveAll
.AllDayEvent = "False"
.BusyStatus = "2"
.ReminderSet = False
.Body = "Hi there," & vbNewLine & vbNewLine & "Could you please arrange for the agents below to be rota'd off to complete a Desk Assessment." & vbNewLine & vbNewLine & "Assessor: " & assessor & vbNewLine & "Staff Member : " & clerk & vbNewLine & "Team: " & team & vbNewLine & "Date: " & datee & vbNewLine & "Time Slot: " & timeslot & vbNewLine & vbNewLine & "Thank You"
.Save
.send
Application.ScreenUpdating = False
Sheets("ACarr").Activate
Range("C14").Select
Selection.ClearContents
Range("C20").Select
Selection.ClearContents
Range("C26").Select
Selection.ClearContents
Range("C32").Select
Selection.ClearContents
Sheets("Menu").Activate
'enable the application to show screen switching again
Application.ScreenUpdating = True
ActiveWorkbook.Save
MsgBox "Your Email has been sent and changes saved."
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End If
End Sub
As far as i can see i have the right amount of End Ifs for the amount of Ifs.