using VBA to make another open mde file the active window

P

Paul

Is there a way VBA can make another open mde file the active window?

That is, if I have two open files, file1.mde and file2.mde, and file1.mde is
the active window, is there code I can run in file1.mde that will make
file2.mde the active window?

Thanks in advance,

Paul
 
L

Lars Brownies

Check out:

http://www.visualbasic.happycodings.com/Applications-VBA/code5.html

with which you can bring an app to the top by its Window Title

There is the following test sub:

'Demonstration routine, brings Excel to foreground and maximises it
Sub Test()
Dim lHwnd As Long

'Get Excel's handle
lHwnd = DialogGetHwnd(, "XLMAIN")
If lHwnd Then
If AppToForeground(, lHwnd, SW_MAXIMIZE) Then
MsgBox "Maximized Excel", vbSystemModal
Else
MsgBox "Failed to Maximised Excel", vbSystemModal
End If
Else
MsgBox "Please open Excel before trying this demonstration"
End If
End Sub

I tested briefly and if you change:

lHwnd = DialogGetHwnd(, "XLMAIN")
into
lHwnd = DialogGetHwnd("YourMDEwindowTitle")

and remove the line
MsgBox "Maximized Excel", vbSystemModal

it will bring your mde to the top and make it the active one.

Lars
 
L

Lars Brownies

And thinking further, you might not need special code. I noticed that if
you open an mdb/mde that is already open, it will make the mde the active
window as well. So opening the mde in vba maybe all you need to do.

Lars
 

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