• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 649
  • Last Modified:

Maximizing Outlook from VB5

I have a user-configurable VB5 application to personalize the way Outlook 97 launches, by selecting Outlook folders to open. In my case it launches three instances of Outlook 97, with the focus on Calendar, Inbox, and our Public contacts, respectively, in three separate Outlook windows.

However, Outlook has no built-in method to maximize itself, so the three windows appear in Restored size, which is not what I want. Neither has the Outlook window a hWnd property that might be passed to an API call. SendKeys is possible but unelegant.

Does anyone know of a reliable method from within VB to maximize an Outlook window? Existing code looks somewhat like this:

Set ol = New Outlook.Application
Set ns = ol.GetNamespace("MAPI")

' Code to retrieve desired folder from application settings
' This is stored in an sFolderPath string variable

Set f = ns.Folders(sFolderPath)
f.Display

' Maximize code should go here
0
FlorisMK
Asked:
FlorisMK
1 Solution
 
FlorisMKAuthor Commented:
Edited text of question
0
 
BodyaCommented:
If you simply manually maximazes all Outlook windows before closing them the next time they will appear maximized...
:)
I know that it isn't an answer. Using SendKeys seems good in the metter.

Good luck,
Bodya
0
 
bruintjeCommented:
Hi Floris,

I haven't Outlook installed so I can't look it up, but there has to be someting like

set ol.windowstate = olWindowMaximized

I know this is the way most OLE automation works, maybe you can look it in the VBA helpfile for outlook. In Project it is PjWindowMaximized, and in Powerpoint it is PpWindowMaximized so I can't be far off.

Hope it helps
:O)
brUINTje.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
intheCommented:
how are you starting outlook
are you starting the apps with a shell call
RetVal = Shell("path_to_outlook",3)
starts outlook maximised and focused.(according to vba file)
Regards Barry
0
 
FlorisMKAuthor Commented:
Bodya,
Wish U were right. I always use Outlook maximized, and so also close Outlook when maximized. Still it launches restored.

Bruintje,
Too bad. Every OLE enabled application works like that, except Outlook. One of my great programming frustrations is that Outlook's object model is completely inconsistent with the other Office apps.

Inthe,
I don't use Shell, because that doesn't give me back a reference to the Outlook window I can use to set the focus in the Outlook window to a given folder.
0
 
bruintjeCommented:
You're right, Outlook uses VBScript for OutLook, so we're looking further into this...............
0
 
bruintjeCommented:
Installed outlook, tripped through the helpfile, but you're right looks like a can't do, only suggestion I can think of is getting the handle of the window and maximizing before going through the rest of the automation code.

something like this

private maximizeoulook() as ?
sub begin
  getting handle
  an API call to maximize the window
end sub

set olobje = createobject("outlook")
maximizeoutlook
olobje.dosomething
etc....

Terrible, can't find a answer I'm even willing to put some points in there myself :O))))
Hope this getting solved in a satisfying manner..
0
 
FlorisMKAuthor Commented:
Okay, here's the solution I came up with, after some heavy thinking:

Determine the caption of the Outlook windows my application creates. Since I set the focus to specific folders, the caption of the windows is something like "Foldername - Microsoft Outlook"

Use the FindWindow API call to determine the window handle of each window by caption.

Use the ShowWindow API call with the window handle from FindWindow to maximize each window.

Want some points, Bruintje?
0
 
bruintjeCommented:
What do I have to do?
0
 
FlorisMKAuthor Commented:
Answer the question, then I can grade your answer. So just enter your 2:30 PM comment again, but now as an answer.
0
 
bruintjeCommented:
OKidOKi
>>>>
something like this

private maximizeoulook() as ?
sub begin
  getting handle
  an API call to maximize the window
end sub

set olobje = createobject("outlook")
maximizeoutlook
olobje.dosomething
etc...
>>>>

Thanks,
Hope you can live with this (pseudo)solution, I don't understand why MS is making it that difficult in getting some sort of standard on the VBA and VBScript languages. Maybe they have the resources to put one programmer behind the keys the other behind the screen and a third to watch them both, we don't have those resources, but it is us who have to customize their apps.
sighhhh...................
:O)
0
 
bruintjeCommented:
Strange when you look at the time we post these things.
0
 
FlorisMKAuthor Commented:
What a brilliant suggestion! How did you ever come up with it (-:?!? As far as times are concerned: it says 'PST', not GMT (no idea what time zone PST is, but I suppose it's some part of the States).
0
 
bruintjeCommented:
Hmmmmm.............Well, I live in the Netherlands from 4.30AM till 12.30PM, all GMT, but indeed it doesn't make much sense to look into GMT. Maybe some parallel universe? Or are we just simple time-travelers without knowing it? :O))))
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now