How to set ActiveWindow.WindowState = olMaximized in late binding
I am trying to open outlook from msaccess using late binding. I want to display the mail message before sending. The code works but when I click send the message stays in the inbox until I manually open the outlook application.
Using objOutlook.ActiveWindow.WindowState = olMaximized in early binding solves this problem but it does not work in late binding.
What I'm I missing. Below is a snippet of my code:
Dim objOutlookApp As Object Dim objOutlookMail As Object On Error Resume Next Set objOutlookApp = GetObject(, "Outlook.Application") If Err.Number = 429 Then Err.Clear Set objOutlookApp = CreateObject("Outlook.Application") End If On Error GoTo 0 Set objOutlookMail = objOutlookApp.CreateItem(olMailItem) With objOutlookMail .To = "email@email.com" .Body = "this is a test2" .Display End With objOutlookApp.ActiveWindow.WindowState = olMaximized
Option Compare DatabaseOption ExplicitConst olMailItem As Long = 0Const olAppointmentItem As Long = 1Const olContactItem As Long = 2Const olTaskItem As Long = 3Const olMaximized = 0Const olMinimized = 1Const olNormalWindow = 2Public Function openOutlook() Dim objOutlookApp As Object 'Comment out when testing early binding Dim strOutLookMsg As String Dim objOutlookMail As Object
no it's not set to nothing. I works find when I use early binding. But don't work with late binding. This means that there is an additional object that I need to declare and set I just don't know which one.
Place
Const olMaximized = 0
at the beginnning of your code
Regards