Word becomes active window - Why again?

S

Slow Flyer

I am writing in VBA using Word.

If I run UserForm1 with no code, UserForm1 becomes the
active window (as expected).

But if UserForm1 includes the suggested code for the use
of msoFileDialogOpen, UserForm1 is no longer the active
window once it is run and the open file selection made.
Instead Word becomes the active window. UserForm1 has to
be clicked to make it the active window again.

How can I make UserForm1 automatically the active window
again (instead of word) following use of
msoFileDialogOpen?



I am greatful for the response by Cindy Meister, to which
I provide give the following information:

Have you set the UserForm to "Modal"?
The behaviour is the same whether UserForm1 ShowModal is
set true or false.

How about having your code select (set the focus in) a
control on the UserForm?
The behaviour is the same when my code selects (sets the
focus in) a control on UserForm1

Which version of Word is this?
It is Word 2002 10.4030.2625


Any other ideas/solutions?
 
D

Doug Robbins - Word MVP

Hi Slow Flyer,

The following will cause the selected document to open behind the userform:

Private Sub CommandButton1_Click()
With Dialogs(wdDialogFileOpen)
If .Display Then
Documents.Open WordBasic.FilenameInfo$(.Name, 1)
End If
End With
End Sub

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
S

Slow Flyer

Thanks for your response.
I am using msoFileDialogOpen to select the name of a
binary data file which I then open for input. I would
have preferred UserForm1 to remain the active window as
messages relating to the processing of the data are
displayed on it. In selecting the filename, the user has
taken no action (intuitively) to change the active window.

Is it possable for UserForm1 to remain the active window
after use of msoFileDialogOpen?
-----Original Message-----
Hi Slow Flyer,

The following will cause the selected document to open behind the userform:

Private Sub CommandButton1_Click()
With Dialogs(wdDialogFileOpen)
If .Display Then
Documents.Open
WordBasic.FilenameInfo$(.Name, 1)
 

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