View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Estaup Estaup is offline
external usenet poster
 
Posts: 8
Default Unable to get TextBoxes property of Worksheet Class Error

I also checked the TB object at that time in the Watch window and verified
that the Parent of the TextBox 2 object is truely sheet 2 and not something
else.

"Estaup" wrote:

Just tried this and I get the same error message on the IF statement line.

I have tried doing the following and got an interesting result:

For Each tb in worksheets(2).TextBoxes
MsgBox(tb.name)
Next tb

I went through the loop and other textboxes that are on the page showed up
in the list but not TextBox 2. In this particular case, TextBox 2 does not
have any text currently entered into its contents.

If I then right-click on the textbox, choose Add Text, then execute the
above code I will get a MsgBox with the TextBox 2 name being displayed.



"JLGWhiz" wrote:

Try it again, I clicked the wron thing.


If Len(Sheets(2).OLEObjects("TextBox1").Object.Text) 0 Then
MsgBox "OK"
End If

TextBoxes is not in the Object Model

"Estaup" wrote in message
...
I have posted elsewhere to try and get resolution on my issue and decided
to
ask for help here as well.

I have an issue that is driving me crazy. I have a workbook that has
multiple sheets and some of these sheets have Textboxes (from the drawing
tool) on the sheet with standard naming (i.e. TextBox 1, TextBox 2, etc.)

I have a button that executes code that takes and builds an external file
with the data from the worksheets, including the TextBoxes. During that
process I am checking to see if those worksheets with TextBoxes have
anything
entered before attempting to grab the contents and write them to the
external
file.

Here is the crazy part. If I open the workbook and without doing anything
else, click the button to process I get the 'Unable to get TextBoxes
property
of Worksheet Class' error message.

If I go to each of the sheets, and click to Add text in each of them, then
click the button to process I do not get the error and everything is fine.

Going nuts on this one.

The IF statement below is where the code breaks with the error:

If Len(Worksheets(2).TextBoxes("TextBox 2").Text) 0 Then
'I loop through grabing text out 255 characters at a time for processing
purposes
End If

Any help would be appreciated.

Thanks.



.