View Single Post
  #10   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 have VBA script that is generating the workbook based on parameters for
each worksheet. When the parameter specifies for a TextBox to be on the sheet
one is being generated using the ActiveSheet.TextBoxes.Add method.

Now the generating VBA code was originally writen for Office 03. Subtle
changes were need when Office was upgraded to 07. So in a since the generated
XLS file with the TextBoxes and VBA code is being produced by 07 I'm guessing
running in "compatibility mode"??

I will run the suggested code and post the results.


"Peter T" wrote:

How are you adding the textboxes to the sheet, I take it not in the way you
described originally.

Referring to your OP
"If I go to each of the sheets, and click to Add text in each"

The "Add Text" button does not appear on a textbox, only Edit Text. This
rather suggests the object named "TextBox 1" is not a textbox at all. Try
these -

Dim tbx as Textbox
For each tbx in activesheet.textboxes
debug.print tbx.name, tbx.text
next

dim shp as shape
for each shp in activesheet.textboxes
debug.print shp.name, shp.type
next


You should expect to see type 17 (msotextbox)

Regards,
Peter T




"Estaup" wrote in message
...
I probably need to clarify too, that the code works just fine in 2007.
These
problems are occuring when the code is run in Excel 2003.

So all results and testing being posted here is all being done in Excel
2003.

"Estaup" wrote:

Sorry for the delay in response. I got pulled to another project right
after
posting this and I am just now getting back.

The worksheet is being created in 2007 but then saved as 97-2003 XLS file
format because most of our customers are still on Office 03.



"Peter T" wrote:

Which version of Excel are you using. You say "Textboxes from the
drawing
tool" which implies 97-2003, however the default names you show imply
inserted in 2007
(ie "TextBox 2" rather than "Text Box 2")

Regards,
Peter T

"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.


.



.