Keeping a User Form on Top

T

Thomas M

Word 2000

Is there a way to keep a user form on top of all windows so that it will
always be displayed, even if the user switches to another application?

--Tom
 
M

mbaird

All user forms are children of the activedocument. You will not be able to
accomplish this without using window API calls.


Mark Baird
 
S

Starbird

I think what you want is the user form to be 'modeless', I believe this can
be accomplished as follows:
oForm.Show vbModeless
 
T

Thomas M

Thanks for the reply. After looking into it some more, I had come to the
same conclusion myself, but I was hoping that there was something that I
missed.

Do you know how to do it using API calls, or can you refer me to a
resource (book, kb article, etc.) where I can research how to accomplish
this goal using API calls?

--Tom
 
T

Thomas M

Thanks for the reply. Unfortunately, vbModeless does not allow the form
to stay on top of all open windows when you switch to another
application.

--Tom
 
M

mbaird

You could look at "Visual Basic Programmers Guide to the Win32 API" by Dan
Appleman. One of the problem with "window" API functions is that they
require a handle to the form. I do not know how to get this handle from a
form in Office.

You can look at http://vsdntips.com/Tips/VBTT/306.aspx. Again, the problem
you may will have with a form in Office is getting a handle to the form
itself so that you can pass that handle into the SetWindowPos function.

Another option would be to build a ActiveX DLL using Visual Basic that
contains a form. You could then call this form from VBA.

What exactly are you trying to accomplish? Do you have access to Visual
Basic .NET?


Mark Baird
 

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

Similar Threads


Top