+ Reply to Thread
Results 1 to 4 of 4

Testing text on a shape

  1. #1
    Ajtb
    Guest

    Testing text on a shape

    Hi

    Why does this line cause an error ?

    If Sheets("Control").Shapes("Type1").Characters.Text = "OUTCOMES" Then C = 2


    But this does not cause an error?

    ActiveSheet.Shapes("Type1").Select
    If Selection.Characters.Text = "OUTCOMES" Then ....


    I would like to check the text on a shape which represents a button
    without having to activate the sheet and select the shape first.

    Any help appreciated on this one.

    Andrew Bourke
    Perth, Australia


  2. #2
    Tom Ogilvy
    Guest

    Re: Testing text on a shape

    ? Sheets("Control").Shapes("Type1").TextFrame.Characters.Text = "OUTCOMES"
    True

    ? Sheets("Control").Shapes("Type1").TextFrame.Characters.Text
    OUTCOMES

    --
    Regards,
    Tom Ogilvy

    "Ajtb" <[email protected]> wrote in message
    news:[email protected]...
    > Hi
    >
    > Why does this line cause an error ?
    >
    > If Sheets("Control").Shapes("Type1").Characters.Text = "OUTCOMES" Then C =

    2
    >
    >
    > But this does not cause an error?
    >
    > ActiveSheet.Shapes("Type1").Select
    > If Selection.Characters.Text = "OUTCOMES" Then ....
    >
    >
    > I would like to check the text on a shape which represents a button
    > without having to activate the sheet and select the shape first.
    >
    > Any help appreciated on this one.
    >
    > Andrew Bourke
    > Perth, Australia
    >




  3. #3
    Ajtb
    Guest

    Re: Testing text on a shape

    Thanks Tom!
    Tom Ogilvy wrote:
    > ? Sheets("Control").Shapes("Type1").TextFrame.Characters.Text = "OUTCOMES"
    > True
    >
    > ? Sheets("Control").Shapes("Type1").TextFrame.Characters.Text
    > OUTCOMES
    >


  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Andrew,

    You can change the text without selecting the worksheet. However, the object has to be selected in order to modify the object. Windows is an object oriented programming enviroment. The Select function lets Windows know which object you want to work with. The following code block can be used anywhere in your code to check the Shapes Text, because it now has a fully qualified path.
    _________________________________________________________________

    For Example - Your code using a fully qualified path in a With Block:

    With Worksheets("Control").Shapes("Type 1")
    .Select
    If .Characters.Text = "OUTCOMES" Then C = 2
    End With

    _________________________________________________________________

    Should work. If not, go have a few pints with your mates, chase a shellar or two and email me [email protected]. Perth was the first city I ever visted in Australia. Loved it.

    Best Wishes,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1