Sheils
asked on
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.Wi ndowState = 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:
Using objOutlook.ActiveWindow.Wi
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
ASKER
I actually do have that:
It does not help
Option Compare Database
Option Explicit
Const olMailItem As Long = 0
Const olAppointmentItem As Long = 1
Const olContactItem As Long = 2
Const olTaskItem As Long = 3
Const olMaximized = 0
Const olMinimized = 1
Const olNormalWindow = 2
Public Function openOutlook()
Dim objOutlookApp As Object 'Comment out when testing early binding
Dim strOutLookMsg As String
Dim objOutlookMail As Object
It does not help
maybe because you set the OL obj as nothing at the end of the code
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found the code required to make it work
Place
Const olMaximized = 0
at the beginnning of your code
Regards