Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Disabling Text Boxes without Greying them out?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NateBuckley - 15 May 2008 06:06 GMT
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.
Rick Rothstein (MVP - VB) - 15 May 2008 06:30 GMT
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

> 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
[quoted text clipped - 6 lines]
>
> Thanks.
NateBuckley - 15 May 2008 06:52 GMT
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.

> Which TextBox are we talking about... an ActiveX one placed on the
> worksheet, a Shapes one from the Drawing toolbar (also placed directly on
[quoted text clipped - 12 lines]
> >
> > Thanks.
Rick Rothstein (MVP - VB) - 15 May 2008 07:41 GMT
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

> My apologies I forgot to mention that key bit of information
>
[quoted text clipped - 19 lines]
>> >
>> > Thanks.
NateBuckley - 15 May 2008 08:30 GMT
Sometimes we gotta kludge. :P

Thanks matey, your help is appreciated muchly.

> 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
[quoted text clipped - 43 lines]
> >> >
> >> > Thanks.
Peter T - 15 May 2008 20:47 GMT
> 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

> 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
[quoted text clipped - 6 lines]
>
> Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.