Excel 2007 not in foreground when launched in Vista or Windows 7

M

Madan

Hello,

I used the following code to launch excel 2007 in Vista or Windows 7 through
automation:

Dim objExcel As Object
Set objExcel = CreateObject("Excel.Application")

'Check whether Excel is installed
If objExcel Is Nothing Then
MsgBox "MS Excel is not installed", vbOKOnly
Else
With objExcel
.Workbooks.Open <filename>
.UserControl = True
.Visible = True
End With
End If

Excel is launched but does not come to the foreground as it used to be in
Windows XP or windows 2003 server.

NOTE: I found the same effect when i launch Word 2007 in Vista, Windows 7
and Windows 2008 server. Also I tested office 2003 in Vista and i have the
same effect ... It seems that this behaviour is caused by Vista based OS.

Does anyone have the same problem?
Any solution for it?

Thanks in advance!
Madan
 
M

Madan

Thanks!

It works but do you know why we need to additioanlly call the AppActivate
from Vista onwards?

It is an extra work for us to add AppActivate to everywhere word or excel is
launched.

Madan
 
O

OssieMac

Hi Madan,

I don't know the reason. I guess that it is something to do with how windows
sets its priorities. However, you should realize that while most of the time
AppActivate is not required with Windows XP, it is not 100% reliable and
sometimes the new application is not the top active window.

I use Outlook to send automated emails and have an option for the user to
Display and edit the email if required. I found that most of the time the
newly created email would be the top active window but sometimes not.

Just for interest an example of the code I use for the newly created email
is as follows (the new Outlook email message takes its window name from the
Subject).

strSubject = "My Test email subject"

AppActivate(strSubject & " - Message")

It does not need the HTML, Rich Text or Plain text that is included in the
window name but it needs the " - Message" appended to the subject name.
 
M

Madan

This behaviour happens in all of the Vista based OS like Vista, windows 2008,
Windows 7 and Windows 2008 R2. This goes to show that XP would be the
preferred OS for some more time until Vista based OS becomes more reliable
and consistent.

Madan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top