How to make Excel the active application

S

Stefan Mueller

I start a VBA macro in Excel. This macro is running several minutes.
During that time I open e.g. the Internet Explorer.
When the VBA macro has finished it shows a MsgBox. Unfortunately I
don't see this message box because Excel is not the avtive application
at that time (the message box is behind the Internet Explorer).

How can I make Excel the active application just after the VBA macro
has finished so that I see the message box?
Stefan
 
S

Susan

i ran into this problem recently while trying to make excel play a midi
file - the windows media player would open & take the focus, and then
not allow a msgbox to show.
after much searching & reading previous postings in the newsgroup, it
is my understanding that you can't force windows to put the focus on an
inactive application........ it's not an excel issue, it's a windows
issue.
susan
 
J

Jim Cone

Give this a try...

Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" _
(ByVal hwnd As Long, ByVal lpText As String, _
ByVal lpCaption As String, ByVal wType As Long) As Long

Sub DoItInFront()
Dim MsgResponse As Long
MsgResponse = MessageBox(hwnd:=0, lpText:="This is a Test", _
lpCaption:="Bring to Front", wType:=vbOKCancel + vbExclamation)
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Stefan Mueller" <[email protected]>
wrote in message
I start a VBA macro in Excel. This macro is running several minutes.
During that time I open e.g. the Internet Explorer.
When the VBA macro has finished it shows a MsgBox. Unfortunately I
don't see this message box because Excel is not the avtive application
at that time (the message box is behind the Internet Explorer).

How can I make Excel the active application just after the VBA macro
has finished so that I see the message box?
Stefan
 

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