Thread: Suspend code
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
john john is offline
external usenet poster
 
Posts: 97
Default Suspend code

I have a procedure that sends e-mails automatically unless
the recipient is not found in which case the following
procedure is called:

Public Function enameadd()

Workbooks("file").Close savechanges:=False
Dim appoutlook As New Outlook.Application
Dim nsoutlook As NameSpace
Dim mfContacts As MAPIFolder
Dim ciContact As ContactItem

' open outlook contacts
Set nsoutlook = appoutlook.GetNamespace("Mapi")
Set mfContacts = nsoutlook.GetDefaultFolder
(olFolderContacts)
'find the contact
Set ciContact = mfContacts.Items.Find("[FullName] = "
& strEname)
If ciContact Is Nothing Then
Set ciContact = mfContacts.Items.Add
ciContact.FullName = strEname
End If
'open outlook form
ciContact.Display

Xlautoupdate 'resends email when recipient is added.

End Function

Control is passed back to the Xlautoupdate and the email
is resent. Is it possible to hold the flow of the
procedure until after the contact form has closed, at the
moment the procedure resends before the contact form is
closed.
Thanks
John