using VBA to make another open mde file the active window

  • Thread starter Thread starter Paul
  • Start date Start date
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
 
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
 
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
 
Back
Top