Disabling Text Boxes without Greying them out?

  • Thread starter Thread starter NateBuckley
  • Start date Start date
N

NateBuckley

Hello, I've been asked by a friend if it's possible to disable a users
ability to edit a text box but still be able to view it without making it
grey'd out and the font bleak and hard to read.

I'd normally just use a label but my friend has already made the controls
how he likes so I don't think he's looking to change it.

Any help would be appreciated.

Thanks.
 
Which TextBox are we talking about... an ActiveX one placed on the
worksheet, a Shapes one from the Drawing toolbar (also placed directly on
the worksheet) or a TextBox Control placed on a UserForm?

Rick
 
My apologies I forgot to mention that key bit of information

The Text Box is on a Spread Sheet, created from the "Control Toolbox". The
one where you need to go into design mode to edit it.
 
Here is one way (it is a kludge, but it does seem to work)... Go into Design
Mode; add another TextBox from the Control Toolbox to the worksheet and give
it the name HiddenTextBox (name is unimportant as long as we know what it is
because we will be referring to it in code); now, move this "hidden" TextBox
completely off-screen (personally, I would place it at the complete
bottom-right-hand corner of the worksheet, in the vicinity of cell IV65536,
so it won't ever be seen); then go back to the TextBox which is to be
"disabled" and double-click it in order to get to the code window for the
worksheet it is on; copy/paste the following code into that code window...

Private Sub TextBox1_GotFocus()
HiddenTextBox.Text = ""
HiddenTextBox.Activate
End Sub

Note that I'm assuming the TextBox that is to be "disabled" is named
TextBox1... if that is not the case, change the TextBox1 in the event
procedure header to the actual name of the TextBox. That is it. Whenever the
user clicks into the "disabled" TextBox, the cursor will be redirected into
the "hidden" TextBox where any and all typing will go. See... I told you it
was a kludge.<g>

Rick
 
Sometimes we gotta kludge. :P

Thanks matey, your help is appreciated muchly.
 
I'd normally just use a label but my friend has already made the controls
how he likes so I don't think he's looking to change it.

FWIW, a label can be made to look pretty much like a textbox.

Regards,
Peter T
 

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