I have no idea why Outlook started--sounds pretty strange to me.
I've deleted Outlook and the problem has gone. Before I deleted it I tried
it on a couple of other spreadsheets - and whenever running code produced
a worksheet object (whether names wks, mysheet, blibble, or whatever), if
I clicked on that object in the Locals window, outlook was launched! Ah
well, it's gone now and good riddance.
But since you used the textbox from the drawing toolbar, you can
delete/ignore
the second routine.
But I'm not sure what: "are they the same as forms?" mean.
Your subject says the textboxes are on the worksheets. Are they really
on
worksheets or are they on something else--maybe a dialog sheet or even a
userform?
Yes, they are on worksheets. I was asking if the textboxes from the
Drawing toolbar were the same as the ones from the Forms Toolbar - I was
confused
======
I don't see what would generate the error, though.
Can you paste the code that you used--I'm guessing a minor typo was added
(maybe????).
Here's the code. (Option Explicit is in the module)
Sub testme01()
Dim TB As TextBox
Dim wks As Worksheet
Dim iCtr As Long
For Each wks In ActiveWorkbook.Worksheets
iCtr = 1
For Each TB In wks.TextBoxes
TB.Name = "TB" & iCtr
iCtr = iCtr + 1
Next TB
Next wks
End Sub
In stepping through it, the routine nicely skips the sheet which has no
textboxes, then in the next sheet, stalls at the first textbox: Run Time
error '13' - Type Mismatch.
I've just performed the following test:
I added two textboxes to the sheet that didn't have any and stepped
through - it worked fine for that sheet but stumbled at the next.
On that next sheet, I deleted all the existing textboxes, and created a
couple of new ones. I stepped through and still it failed on this sheet.
I tested the other sheets to make sure it was failing on them and it
wasn't just a problem with the one sheet.
So I seem to have several sheets where, when I add textboxes to them, they
don't get recognised as textboxes?
Darren