Reply
 
Thread Tools Display Modes
  #1   Report Post  
bh
 
Posts: n/a
Default How do I bring the Word window to front?

I've actually done a lot of Mailmerge related driving of Word for years using
OLE, but the one nagging problem is there does not seem to be a method
equivalent to Windows' SetForegroundWindow().
Our app's users really don't want to have to click the taskbar after already
starting a merge. Is there an undocumented Application method to do this?
Or a property where I can get the window handle?
Thanks!

  #2   Report Post  
AA2e72E
 
Posts: n/a
Default

Try (in a module):

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As
Long) As Long
Sub FL()
Dim lHandle As Long
lHandle = FindWindow("OpusApp", vbNullString)
If 0 lHandle Then SetForegroundWindow (lHandle)
End Sub


"bh" wrote:

I've actually done a lot of Mailmerge related driving of Word for years using
OLE, but the one nagging problem is there does not seem to be a method
equivalent to Windows' SetForegroundWindow().
Our app's users really don't want to have to click the taskbar after already
starting a merge. Is there an undocumented Application method to do this?
Or a property where I can get the window handle?
Thanks!

  #3   Report Post  
bh
 
Posts: n/a
Default

Thanks! I was able to implement a workaround with FindWindow. The trick was
that there are multiple Word windows open at the time, so I had to first get
the window title from ActiveDocument.Name + " - Microsoft Word".
Still, it's awfully crazy to have such power with an Object, yet have to go
to such lengths for a basic operation.

Does anyone know if there's a Application, Document, or Window method that
would push it to front?

bh


"AA2e72E" wrote:

Try (in a module):

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As
Long) As Long
Sub FL()
Dim lHandle As Long
lHandle = FindWindow("OpusApp", vbNullString)
If 0 lHandle Then SetForegroundWindow (lHandle)
End Sub


"bh" wrote:

I've actually done a lot of Mailmerge related driving of Word for years using
OLE, but the one nagging problem is there does not seem to be a method
equivalent to Windows' SetForegroundWindow().
Our app's users really don't want to have to click the taskbar after already
starting a merge. Is there an undocumented Application method to do this?
Or a property where I can get the window handle?
Thanks!

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I divide a page into three sections? Bonnie Microsoft Word Help 3 May 8th 23 02:47 AM
When I bring up Word, it comes up minimized. Tugger Microsoft Word Help 2 December 12th 04 05:05 PM
saving the workspace Mike Microsoft Word Help 3 December 9th 04 12:32 AM
how do i open multiple documents in one word window? mac word x sanlireis Microsoft Word Help 2 November 26th 04 10:57 AM
why does my new word xp file window flash and lock up? miki Microsoft Word Help 2 November 24th 04 08:54 PM


All times are GMT +1. The time now is 09:01 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"