Text Box Scroll Bar question

R

RJQMAN

Please forgive my posting this in two groups, but I have not had any
response in the Program group, and I need some help.

I am trying to use a text box on a page (not on a User Form), and I
have pre-loaded information in the box, so that it can be scrolled and
viewed by the user. I would like to do the following, but do not know
how to do it, or even if it is possible;

1) I would like to 'lock' the text so that the user cannot change it.
2) I would like the scroll bar to be at the top whenever the worksheet
is accessed.

The worksheet can only be accessed by a macro, so I could use code for
one or both of these things, but I do not know how to approach it. I
would really appreciate some help. Thanks in advance.
 
D

Daniel.C

In a standard module, paste :
Public Tb As String
In the "ThisWorkbook" module, paste :
Private Sub Workbook_Open()
Tb = Sheets("Sheet1").TextBox1.Text
End Sub
This will serve to keep the initial value of the textbox.
In the sheet module, paste :
Private Sub TextBox1_Change()
Me.TextBox1 = Tb
End Sub
This will restore the initial text each time it will be modified.
Please note that the text is restored when the textbox loose the focus.
Also, paste :
Private Sub Worksheet_Activate()
TextBox1.Activate
TextBox1.CurLine = 1
Tb = TextBox1.Text
End Sub
to get the beginning of the text of the textbox when the sheet is
selecteed.
HTH
Daniel
 
R

RJQMAN

In a standard module, paste :
Public Tb As String
In the "ThisWorkbook" module, paste :
Private Sub Workbook_Open()
Tb = Sheets("Sheet1").TextBox1.Text
End Sub
This will serve to keep the initial value of the textbox.
In the sheet module, paste :
Private Sub TextBox1_Change()
    Me.TextBox1 = Tb
End Sub
This will restore the initial text each time it will be modified.
Please note that the text is restored when the textbox loose the focus.
Also, paste :
Private Sub Worksheet_Activate()
    TextBox1.Activate
    TextBox1.CurLine = 1
    Tb = TextBox1.Text
End Sub
to get the beginning of the text of the textbox when the sheet is
selecteed.
HTH
Daniel







- Show quoted text -

Wow! Hello Daniel. Thanks so very much. It worked!
FYI - I had to change the curline to "0" instead of "1"in order for
the box to go to the very top line.
Also as far as user changes, it worked even better than expected,
because with the sheet protected, I found that the user cannot change
the text at all. That is exactly what I wanted and what I had hoped
for.
Thanks again.
 

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