Hello Access Programmers,
This issue has come up here before, under slightly different circumstances, but I do not recall seeing it solved.
http://www.access-programmers.co.uk/forums/showthread.php?t=159151
http://www.access-programmers.co.uk/forums/showthread.php?t=249217
I have an Access application that uses Outlook to send email. When I run the Access application with Outlook open and minimized to the taskbar, Outlook behaves as it should; when .display is executed the email window opens on top of the application.
However, if Outlook is not open, the email window opens behind the Access application, with the taskbar icon blinking.
I think the issue may be with Outlook’s Object Model Guard http://msdn.microsoft.com/en-us/library/office/ff864479.aspx but, my antivirus is registered and up to date.
Does anyone know of a method to bring the Outlook email window into focus or any other solution or workaround to this issue?
This issue has come up here before, under slightly different circumstances, but I do not recall seeing it solved.
http://www.access-programmers.co.uk/forums/showthread.php?t=159151
http://www.access-programmers.co.uk/forums/showthread.php?t=249217
I have an Access application that uses Outlook to send email. When I run the Access application with Outlook open and minimized to the taskbar, Outlook behaves as it should; when .display is executed the email window opens on top of the application.
However, if Outlook is not open, the email window opens behind the Access application, with the taskbar icon blinking.
I think the issue may be with Outlook’s Object Model Guard http://msdn.microsoft.com/en-us/library/office/ff864479.aspx but, my antivirus is registered and up to date.
Does anyone know of a method to bring the Outlook email window into focus or any other solution or workaround to this issue?
Code:
Function SendEmail()
On Error GoTo SendEmail_Err
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = varAddress
.CC = varCC
.BCC = varBCC
.Subject = varSubject
.Body = varBody
.Importance = varImportance
.Display ' (Deactivate to Auto-Send)
' .send ' (Activate to Auto-Send)
End With
SendEmail_Exit:
Exit Function
SendEmail_Err:
MsgBox "Public Function: SendEmail" & Chr$(13) & _
"Error number: " & Err.Number & Chr$(13) & _
Err.Description, vbOKOnly, "modPublic"
Resume SendEmail_Exit
End Function