scrollbar on userform

  • Thread starter Thread starter S.Hoitinga
  • Start date Start date
S

S.Hoitinga

Hi,

I created a form with user instructions on how to work with key-combinations
in excel and saved it as an xla.
The form pops up on key ctrl+shift+X.

The form covers more or less the complete monitor-window (especially on
monitors of 15" or less).
Now I would like to place a scroll-bar on the form, which would it possible
to show only an small part of the form.
I placed a scroll-bar on the form, but I can't figure out what the code
should be to have the form scrolling in its window.

Does anyone have any suggestions?

Any help is greatly appreciated.

Sybolt
 
There are properties for the UserForm.

Try playing with
ScrollBars = fmScrollBarsBoth
ScrollHeight = 5000
ScrollWidth = 5000

Then at design time, you can place controls outside of the visible area by
using the scrollbars.
 
You may want to look at using a multipage control, too.

You could make it look a lot like the Tools|options dialog
(well, except with yours, you could find what you're looking for <vbg>)
 
Private Sub UserForm_Initialize()
Me.ScrollBars = fmScrollBarsVertical
Me.ScrollHeight = Me.Height
Me.Height = 0.5 * Me.Height
End Sub
 
Thanks everybody,

I used a combination of Tom's and Rob's suggestions.
like this:

Private Sub UserForm_Initialize()
Me.ScrollBars = fmScrollBarsVertical
Me.ScrollHeight = 400
Me.Height = 0.3 * Me.Height
End Sub

A new problem occurred however.

When the form pops up it focuses on the vertical end of the form, where I
would like the form to focus on the vertical top of the form.
Has this anything to do with a command button, which is at the end of the
form? This button has the focus (automatically) because I want users to be
able to push Enter to close the form?

greets,

Sybolt
 
From what I can gather, this has to do with the TabIndex property.

The form can be navigated by keyboard using the tab key. Each control has a
TabIndex which sequences which control gets focus as Tab is pressed.
 
From what I can gather, this has to do with the TabIndex property.

The form can be navigated by keyboard using the tab key. Each control has a
TabIndex which sequences which control gets focus as Tab is pressed.

That's just what my idea was.
I tried to give the first object (a lable) the first tab-key, but this
didn't change a thing.
Also I set the property "setfocusonclick" of the comandbutton to false, but
still the focus was on the end of the form.
I don't want people to first use the Tab to get to the top of the form. The
form should show the top when popping up.

It seems to be out of control.
Weird.
 
Each control has their own TabIndex. Ensure that the top-most control has
the lowest TabIndex number.
 

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

Back
Top