Solved Stop code until other application finished

Mister-B

New member
Local time
Today, 09:56
Joined
Apr 10, 2020
Messages
16
I have finally gotten my code to work. From my form I create an outlook appointment from data on the form and send it to recipients that are also on the form. After generation the appointment is displayed in Outlook and I check for errors or may add notes manually. After all is OK I send the appointment manually by clicking the send button. While I am checking the appointment, the original code on my access form is continuing to run. Is there any way to make it stop or pause until i have actually sent the appointment?
 
Depending on what the rest of the code is doing, you may be able to make the code wait.
 
You could simply raise a MsgBox with text "Click OK when displayed Calendar item is sent"
Add it after your .Display line of code for Outlook item
 
You could simply raise a MsgBox with text "Click OK when displayed Calendar item is sent"
Add it after your .Display line of code for Outlook item
Actually that is actually what I am doing, but the message appears before I have finished tending to Outlook.
 
Can you post your complete code so we can see what's goin on? From what you are describing, there may be a couple of options.
 
Actually that is actually what I am doing, but the message appears before I have finished tending to Outlook.
Yeah, that's what is supposed to happen.
You don't click OK until you're finished sending outlook.
The advantage here is a MsgBox is modal
 
The OutlookItem.Display() method takes an optional Modal parameter which defaults to False. If you set it to True, I think your code will pause at that line.

Code:
Private WithEvents oli_ As Outlook.AppointmentItem
Private cli_ As cOLCalendarItem

    '  . . .

    Set cli_ = Services.OLCalendarItem.GetByID(HashID)
    Set oli_ = Services.OLCalendar.GetAppointment(cli_.EntryID)
    If Not oli_ Is Nothing Then oli_.Display True
    ' code pauses execution until you close the OutlookItem
 
Funny I'd never even noticed that optional parameter before! Guess I wasn't paying attention.
Learned something new, thanks Mark
 
Thanks for all the input guys. MarkKs information about the optional parameter for OutlookItem.Display is just the ticket and solves my problem.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom