Solved

Maximizing Outlook from VB5

Posted on 1999-01-22
14
635 Views
Last Modified: 2008-03-03
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
Comment
Question by:FlorisMK
14 Comments
 
LVL 2

Author Comment

by:FlorisMK
ID: 1615903
Edited text of question
0
 
LVL 2

Expert Comment

by:Bodya
ID: 1615904
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
 
LVL 44

Expert Comment

by:bruintje
ID: 1615905
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
 
LVL 17

Expert Comment

by:inthe
ID: 1615906
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
 
LVL 2

Author Comment

by:FlorisMK
ID: 1615907
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
 
LVL 44

Expert Comment

by:bruintje
ID: 1615908
You're right, Outlook uses VBScript for OutLook, so we're looking further into this...............
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1615909
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 2

Author Comment

by:FlorisMK
ID: 1615910
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
 
LVL 44

Expert Comment

by:bruintje
ID: 1615911
What do I have to do?
0
 
LVL 2

Author Comment

by:FlorisMK
ID: 1615912
Answer the question, then I can grade your answer. So just enter your 2:30 PM comment again, but now as an answer.
0
 
LVL 44

Accepted Solution

by:
bruintje earned 100 total points
ID: 1615913
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
 
LVL 44

Expert Comment

by:bruintje
ID: 1615914
Strange when you look at the time we post these things.
0
 
LVL 2

Author Comment

by:FlorisMK
ID: 1615915
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
 
LVL 44

Expert Comment

by:bruintje
ID: 1615916
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

How many times recently have you prepared a presentation or emailed a document to a client and you have found that they have older versions of MS Office and they can not open the file you have prepared.  Although most visitors to this site are exper…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now