J'ai travaillé sur le code ci-dessous pendant des jours, j'espère que le produit final fera 2 choses.fin si sans bloc si
Envoyez un e-mail à un organisateur d'équipe avec les détails de la feuille de calcul. Envoyez un rendez-vous à l'évaluateur du bureau avec les détails du rendez-vous.
Je reçois un message d'erreur indiquant:
Compile Erreur:
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 = "[email protected]"
.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 = "[email protected]"
.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
Pour autant que je peux voir, je la bonne quantité de fin Ifs pour le montant de Ifs.
'Avec OutMail ..' manquant sa' Fin With' –
S'il vous plaît pardonnez-moi, je ne comprends pas ce que tu veux dire? –
Vous avez 'Avec OutMail' donc il doit y avoir un' End With 'correspondant pour le fermer - il n'y en a pas pour le moment. Vraisemblablement, vous en avez besoin après '.send' –