How to make Scroll Bar work on a form

G

Guest

Hi all,

After set Scrollbars and KeepScrollbarVisible on my form, there are scroll
arrow in two end of the bar, but no scroll handler in the middle of the bar.
Actually, there is a textbox whose lenght is already over the form length.

Clara
 
G

Guest

I assume you want the user to be able to scroll the userform vertically:

In design mode in the VBE, the userform should be large enough hold all the
controls.

Use code like this in the Userform Initialize event:

Private Sub UserForm_Initialize()
UserForm1.ScrollBars = fmScrollBarsVertical
UserForm1.KeepScrollBarsVisible = fmScrollBarsNone

UserForm1.Height = UserForm1.Height / 2
UserForm1.ScrollHeight = 2 * UserForm1.Height
' UserForm1.ScrollWidth = 2 * UserForm1.Width


End Sub
 
G

Guest

Hi Tom,

Thank you very much! It works, but why cann't I do it in properties window
of a form.

Clara
thank you so much for your help
 
G

Guest

Hi Tom,
It also works when i set the scrollheight and scrollwidth in design mode.
Thanks Tom

Clara
 
D

Dave Peterson

You can.

Select your user form and hit F4 to see the properties

Look for each of the properties that Tom used:

..scrollbars
..KeepScrollBarsVisible
..height
..scrollheight

And modify each the same way Tom's code did.

Since Tom changed the .height to .height/2, you do the same (360 become 180,
500 becomes 250, etc).

And .scrollheight is 2*.height you used.

(And remember to comment out the code--else you'll be doing it twice.)
 

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