What I need to do is add a scroll bar to my text box in my form. I used the properties of the text box to add a scroll bar but when you preview it you can't see it. When you click somewhere inside the form it appears and is workable but not when it hasn't been clicked on. How do I make the scroll bar appear from the start. this is a vertical one ad is on a text box within the form
Last edited by dextras; 07-04-2009 at 07:12 AM.
The TextBox MultiLine Property needs setting to True. The scrokkbar will become visible as data is entered
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
Already done. The textbox already has data in it. I am not using it as a thing to be able to have data entered into it. I guess I should be using something else. Label? If so how would then deal with the scroll vars
What data are you putting in? maybe you could use a listbox
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
This works for me.
Userform textbox and command button
If the textbox is first in the Tab order the activation event code in not required.Code:Private Sub UserForm_Activate() Dim objTemp As Object Set objTemp = Me.ActiveControl TextBox1.SetFocus objTemp.SetFocus End Sub Private Sub UserForm_Initialize() With TextBox1 .ScrollBars = fmScrollBarsVertical .MultiLine = True .WordWrap = True .Text = "Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text" End With End Sub
The scrollbars are only displayed if the text is long enough.
Here's my spreadsheet. How would I add in the code? I'm not sure where you'd add it. It's for the "help" userform.
Just add this to your userform
Code:Private Sub UserForm_Initialize() Me.TextBox2.SetFocus End Sub
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
That works except it focuses to the bottom of the scroll box. This means that then you are scolled to the bottom when you open it. How can i fix this?
All you actually need in your userform, to fix the problem, is the following.
Code:Private Sub UserForm_Initialize() With TextBox2 .TabIndex = 0 .ScrollBars = fmScrollBarsVertical .SelStart = 0 End With End Sub
Thank you, that's exactly what i needed. I would have thought that you wouldn't need to do all that other stuff to get it done
+1
Your post does not comply with Rule 9 of our Forum RULES. If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit. And please never edit a thread in which someone else has responded.
How to mark a thread Solved
Go to the first post
Click edit
Click Go Advanced
Just below the word Title you will see a dropdown with the word No prefix.
Change to Solved
Click Save
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks