Active Window

C

Chad Knudson

I am dealing with a large set of legacy document templates. In an attempt
to get some control over these, I wrote a little template manager template
that allows the user to follow a wizard process to answer a few questions
and then the template manager creates a new document based on one of the old
legacy templates. The old legacy templates in turn pop up some WordBasic
input boxes to get some additional information from the user. Often this
process involves moving the selection to a bookmark location of the new
document, asking for some information, and then it fills in the blank
allowing the user to see the document changes as they take place.

The problem I'm having is that if I use a regular VBA MsgBox, the template
manager is brought to the foreground instead of the user's new document.
The user isn't able to see their new document and is unable to make their
choices as to what information needs to go in those input boxes when
"working blind." Sometimes the WordBasic.MsgBox doesn't exibit this
behavior (leaving the newly created document in the front) but other times
it brings the template manager to the front. The VBA MsgBox always brings
the template manager to the front. Is there any way I can change this?
 
J

JB

Chad said:
I am dealing with a large set of legacy document templates. In an attempt
to get some control over these, I wrote a little template manager template
that allows the user to follow a wizard process to answer a few questions
and then the template manager creates a new document based on one of the old
legacy templates. The old legacy templates in turn pop up some WordBasic
input boxes to get some additional information from the user. Often this
process involves moving the selection to a bookmark location of the new
document, asking for some information, and then it fills in the blank
allowing the user to see the document changes as they take place.

The problem I'm having is that if I use a regular VBA MsgBox, the template
manager is brought to the foreground instead of the user's new document.
The user isn't able to see their new document and is unable to make their
choices as to what information needs to go in those input boxes when
"working blind." Sometimes the WordBasic.MsgBox doesn't exibit this
behavior (leaving the newly created document in the front) but other times
it brings the template manager to the front. The VBA MsgBox always brings
the template manager to the front. Is there any way I can change this?
Hi Chad,

I've written a small function to handle window managment of sorts. This
isn't exactly what your looking for but you can easily modify it to do
what you want.

'you can pass a variable with the document name you wish to bring to the
'foreground and change the my.close to active or setfocus I'm not sure
'as I haven't tested it but you get the Idea yeah?
'Just call it like CheckWins DocNametoActivate

Public Function CheckWins(byref MyDocName as string)
Dim myWin As Window

If Application.Windows.Count > 1 Then
For Each myWin In Application.Windows
If (InStr(myWin.Document.Name, MyDocName)) Then
myWin.Close (wdDoNotSaveChanges)
End If
Next
Else
Application.Quit (wdDoNotSaveChanges)

End If

End Function

HTH

J
 

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