PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Program Addins
Prompt a msgbox and try to cancel a close action
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook Program Addins
Prompt a msgbox and try to cancel a close action
![]() |
Prompt a msgbox and try to cancel a close action |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
hi, What I want to do is to give the user a message if he does not connect
appointment to any contact and tries to close the inspector. If he choose to cancel the close, how to cancel it? Here is my code. But it always close, even after msgbox shows up and click no. Private Sub objApptItem_Close(Cancel As Boolean) Dim myLinks As Links On Error Resume Next Set objApptItem = objInsp.CurrentItem Set myLinks = objApptItem.Links If myLinks.Count = 0 Then If MsgBox("This appointment has no contact related, do you want to exit?", vbOKCancel, "Appointment Exit") = vbYes Then Cancel = True Exit Sub End If End If Cancel = False End Sub |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Sorry, the question is partly solved by change cbYes to vbCancel.
However, sometimes the event does not fire at all, any opinion? Thanks "song" <gray_song@yahoo.com> wrote in message news:ObBfm36VEHA.3740@TK2MSFTNGP12.phx.gbl... > hi, What I want to do is to give the user a message if he does not connect > appointment to any contact and tries to close the inspector. If he choose to > cancel the close, how to cancel it? > > Here is my code. But it always close, even after msgbox shows up and click > no. > > Private Sub objApptItem_Close(Cancel As Boolean) > Dim myLinks As Links > On Error Resume Next > Set objApptItem = objInsp.CurrentItem > Set myLinks = objApptItem.Links > If myLinks.Count = 0 Then > If MsgBox("This appointment has no contact related, do you want to > exit?", vbOKCancel, "Appointment Exit") = vbYes Then > Cancel = True > Exit Sub > End If > End If > Cancel = False > End Sub > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Try explicitly setting the return value from the MsgBox function to an
Integer first and then test the Integer value and see if that helps. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "song" <gray_song@yahoo.com> wrote in message news:ui4q786VEHA.2928@tk2msftngp13.phx.gbl... > Sorry, the question is partly solved by change cbYes to vbCancel. > > However, sometimes the event does not fire at all, any opinion? > > Thanks |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

