How to make objects "float"?

J

Jason

Is there a way to make objects "float" on the screen? In other words, stay
in the same screen position, while the user is scrolling vertically and
horizontally? I am specifically dealing with combo boxes that need to remain
visible in a lengthy document.

TIA

Jason
 
H

Helmut Weber

Hi Jason,

you may find a userform of type vbmodeless usefull.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
J

Jason

Thanks very much for the quick reply, Helmut.

Can you expound a little on how to make it vbmodeless? In the VBA object
browser, I can only find msoModeModeless, and I do not know how to assign
this property to the userform (by the way, thanks for the great suggestion).

Also, how do I set the userform to always appear in the upper-right corner
of the active document?

I really appreciate your help.

Jason
 
H

Helmut Weber

Hi Jason,

in principle:

Sub Test1111()
UserForm1.Show vbModeless
UserForm1.Top = 5
UserForm1.Left = 400
End Sub

So far so good.

A really professional solution would have
to find out the screen resolution beforehand,
the size of the userform and so on.
Maybe the size of the window,
whether it is maximized or not,
then its position...



HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
J

Jason

Based on reading a past thread, it appears as though vbModeless is not
available in Word 97 (current version, sorry I forgot to mention). Is this
accurate? If so, is there another solution to my dilemma?

Thanks again!

Jason
 
H

Helmut Weber

Hi Jason,
Based on reading a past thread, it appears as though vbModeless is not
available in Word 97 (current version, sorry I forgot to mention). Is this
accurate? If so, is there another solution to my dilemma?

that's bad.

It is beyond my knowlegde,
apart from programming another Word.Application yourself.

Sorry.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
D

Doug Robbins - Word MVP

I copied this from a September 19, 2000 post by Jasper Mandos.

Quote

The next piece of code will set the current form modeless.
It relies on some sort of bug(feature) in Word.
The only problem remains is, that when the form re-gets it focus after you
done the things you wanted to do in the word window,
no event is triggered. But, for your form this does not seem to be needed.

Public Declare Function GetActiveWindow Lib "User32" () As Long
Public Declare Sub SetActiveWindow Lib "User32" (ByVal hWnd As Long)

Sub SetMeModeless(KeepFocus As Boolean)
Dim hWnd As Long
hWnd = GetActiveWindow
SendKeys ("{ESC}")
Dialogs(wdDialogFileOpen).Display
' use this line when the sendkey does not work, but it's a little bit
' slower: Dialogs(wdDialogFileOpen).Display (1)
If KeepFocus Then SetActiveWindow (hWnd)
End Sub

Unquote
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Jason

Hi, Doug. Thank you for the timely reply. I was finally able to test the
below code, but I cannot seem to figure out how to call this macro. Here are
the steps I took:

I have the load and show userform commands in a separate macro.

I have copied and pasted the code you provided into a separate general module.

Then, in the userform_initialize event, I try to call the below macro using
both of the following, and neither seems to work:

Call SetMeModeless
Application.Run "SetMeModeless"

I am receiving an error stating, "Unable to run the specified macro."

Any ideas?

Thanks again.

Jason
 
D

Doug Robbins - Word MVP

Sorry, I never had the need to use it and have long since moved on from Word
97.

I suggest that you re-post this to the userforms newsgroup where you may
attract the attention of someone who had used it and may be able to help.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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