|OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.|
Frequently, Outlook developers need to display a formular to a user to request some data while the user is working on an e-mail.
There's a problem if Word is used as e-mail editor: Your Addin or VBA code runs in the process of Outlook while the e-mail editor runs in the process of Word. That means for instance, you cannot show your formular modal to the mail window; without tricks you even cannot get the mail window on top or give it the focus.
Dr. JÃ¼rgen ThÃ¼mmler provides the DLL dsmodal for free: With that you can easily make any window modal to a window of an other process or even make it modal to all the system.
This sample demonstrates how to obtain the window handles and use dsmodal. Please copy the dsmodal.dll into the system directory (..winntsystem32) so that it will be found.
The sample uses a VB6 formular. Before loading it, please set the ParentWindowCaption to the caption of the mail window (Inspector.Caption).
With a few changes you can also use it in VBA code. Because the UserForm of the Office library doesn't know the Form_Load event, you could call the code e.g. once in the Inspector_Activate event. Additionally, the UserForm doesn't have a property for its window handle. But with its caption property and the FindChildWindowText function you can get the handle easily.
Private Declare Function MakeModal& Lib "dsmodal" _ (ByVal AppHwnd&, ByVal hwndDest&, Optional ByVal Beep& = 0) Public ParentWindowCaption As String Private Sub Form_Load() Dim lParent As Long Dim lMe As Long lParent = FindChildWindowText(GetDesktopWindow, ParentWindowCaption) ' VB Forms: lMe = Me.hwnd Call MakeModal(lMe, lParent, 1) End Sub Private Sub Form_Unload(Cancel As Integer) Call MakeModal(0, 0, 0) End Sub
|Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.|