Spell Checking Text Boxes?

D

Don Wiss

My text boxes are now all from the Shapes or Forms toolbars. I believe the
objects are the same. Alongside each box I have a button for spell
checking. The macro the button called had the text box's name to know which
to select and check. The sheet is protected. I thought I could have a
single macro that with Selection.Name could determine where the user was
and then use that to select the shape to check. But it seems that when
protected you can't read the Selection.Name.

Okay, so I can go back to my old way. But even then it is less than
perfect. After checking the spelling the textbox is left with the fuzzy
line around it. When the user leaves the box it does go away, but returns
when the box is reselected. The box is no longer protected. It can be
moved. But only once. Then this goes away and it becomes a normal protected
box.

I then decided to see what a text box from the control toolbox would do. Of
course this means much more complexity. I created a box. It has WordWrap =
True. MultiLine = True. EnterKeyBehavior = True. SelectionMargin = False.
One quirk I see is if there is more text than can be shown, the hidden text
is from the top. Then why does the box and text increase in size slightly
when selected? And then I get back to my original question and just how
would I spell check these?

Don <donwiss at panix.com>.
 
D

Dave Peterson

I'm not sure what textboxes you're using.

I put a couple of textboxes from the Drawing toolbar onto a worksheet. I put a
couple of buttons from the Forms toolbar onto the sheet (adjacent to the
textboxes).

But I named each nicely.

the buttons were named: button_001 and button_002
the textboxes were named: textbox_001 and textbox_002

Then I could use those suffixes from the button's name to determine which
textbox to spellcheck.

I put this in a general module:

Option Explicit
Sub testme()

Dim myBTN As Button
Dim mySFX As String
Dim myTB As TextBox

Set myBTN = ActiveSheet.Buttons(Application.Caller)
mySFX = Right(myBTN.Name, 3)
Set myTB = ActiveSheet.TextBoxes("TextBox_" & mySFX)

myTB.CheckSpelling

End Sub

And assigned it to both buttons.
 
D

Don Wiss

I'm not sure what textboxes you're using.

When I wrote Shapes and Forms I meant from the Drawing and Forms toolbars.
I put a couple of textboxes from the Drawing toolbar onto a worksheet. I put a
couple of buttons from the Forms toolbar onto the sheet (adjacent to the
textboxes).

But I named each nicely.

the buttons were named: button_001 and button_002
the textboxes were named: textbox_001 and textbox_002
Clever.

Then I could use those suffixes from the button's name to determine which
textbox to spellcheck.

I put this in a general module:

Option Explicit
Sub testme()

Dim myBTN As Button
Dim mySFX As String
Dim myTB As TextBox

Set myBTN = ActiveSheet.Buttons(Application.Caller)
mySFX = Right(myBTN.Name, 3)
Set myTB = ActiveSheet.TextBoxes("TextBox_" & mySFX)

myTB.CheckSpelling

End Sub

And assigned it to both buttons.

This works fine. Thanks. What I had been doing is to select the shape, then
run the spell check on it. By avoiding the selection you avoided the
problem I was having. While this way is fine, I had been hoping to replace
all the alongside buttons and have a single button on my toolbar. But that
would require the user to have the focus in the text box. My old way, a
macro for each text box, and your enhancement, allows for the focus to be
anywhere. This is better. So I will go with this and drop the toolbar idea.

Don <donwiss at panix.com>.
 

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