Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Excel Office for Mac > finding text in...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 5627 of 6433
Post > Topic >>

finding text in all textboxes

by =?Utf-8?B?THVya2luZ01hbg==?= <LurkingMan@[EMAIL PROTECTED] May 16, 2008 at 09:55 AM

Hi All:
I'm new to VBA and Excel and have probably made an elementary error, or 
several. 
I'm trying to retreive  text from all the textboxes (the kind added by the

drawing toolbar) on all the sheets of multiple open workbooks.

I think I've gotten the iteration right, but in the two Subs below, the
code 
snippet 
theText = x.TextFrame.Characters.Text  
seems to not work when x is in a group, even though I'm checking to verify

that x is in fact a text box.

Any help is appreciated. Here's code demonstrating the problem/my
confusion.


'Visit all sheets in all open workbooks and call FindTB on each
Sub SearchAllTBs()
    For i = 1 To Workbooks.Count
        Workbooks(i).Activate
        For j = 1 To Sheets.Count
            Worksheets(j).Activate
            For Each s In ActiveSheet.Shapes

'Some testcode: Getting text from a shape that's a textbox always works
here.
                If s.Type = msoTextBox Then
                    xx = s.TextFrame.Characters.Text
                    MsgBox (xx)
                End If
 
               FindTB s
            Next
        Next j
    Next i
End Sub

'Visit all (shape)text boxes on the active sheet,
'even if they're in a group
Sub FindTB(s)
    If s.Type = msoTextBox Then
        xx = s.TextFrame.Characters.Text
'The same line  ^^ gets Error 2042 here...
        MsgBox (s.Name)   
'even though the object seems to be the expected text box.

    ElseIf s.Type = msoGroup Then
        Set gs = s.GroupItems
        For i = 1 To gs.Count
            Set x = gs.Item(i)    'so x must be somehow wrong?
            FindTB x
        Next
    End If
End Sub
-- 
In theory, there''s no difference between theory and practice.
In practice, there''s no similarity.
 




 5 Posts in Topic:
finding text in all textboxes
=?Utf-8?B?THVya2luZ01hbg=  2008-05-16 09:55:04 
Re: finding text in all textboxes
JE McGimpsey <jemcgimp  2008-05-16 13:41:13 
Re: finding text in all textboxes
=?Utf-8?B?THVya2luZ01hbg=  2008-05-16 14:28:01 
Re: finding text in all textboxes
JE McGimpsey <jemcgimp  2008-05-16 17:40:59 
Re: finding text in all textboxes
=?Utf-8?B?THVya2luZ01hbg=  2008-05-19 13:07:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 11:22:07 CDT 2008.