Consulting

Results 1 to 6 of 6

Thread: Solved: Still hate shapes...

  1. #1
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location

    Solved: Still hate shapes...

    If there is a shape of type 6 (whatever THAT means)...how do I add text to it?

    The Shape's name is AddressShape...here's what I've tried:
    [VBA]
    Sub SHAPE()
    Dim oShape As Object
    Set oShape = ActiveSheet.Shapes("AddressShape")

    oShape.TextFrame.Characters.Text = "Joe"
    End Sub

    Sub Shape2()
    ActiveSheet.Shapes("AddressShape").TextFrame.Characters.Text = "Joe"
    End Sub

    Sub Shape3()
    Dim oShape As Object
    Set oShape = ActiveSheet.Shapes("AddressShape")

    oShape.OLEFormat.Object.TextFrame.Characters.Text = "Joe"
    End Sub[/VBA] Yet no luck

    I don't want to select the shape either...BTW

    .......

    God I hate shapes....




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    You see what's happened? First you got angry, the anger's led to hate... I think you know where that path goes - not that the dark side doesn't have it's uses
    But your ire is misplaced, type 6 is a group - you can't add text to a group, you'll either have to ungroup the group or get one of the groupitems that can have text added to it

    Its always worth testing something to see what it is before you try do do stuff with it here's the shape constants and their values

    msoAutoShape 1
    msoCallout 2
    msoCanvas 20
    msoChart 3
    msoComment 4
    msoDiagram 21
    msoEmbeddedOLEObject 7
    msoFormControl 8
    msoFreeform 5
    msoGroup 6
    msoLine 9
    msoLinkedOLEObject 10
    msoLinkedPicture 11
    msoMedia 16
    msoOLEControlObject 12
    msoPicture 13
    msoPlaceholder 14
    msoScriptAnchor 18
    msoShapeTypeMixed -2
    msoTable 19
    msoTextBox 17
    msoTextEffect 15
    K :-)

  3. #3
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Although I don't think it's the cause of your problem here, you also have a reserved word (SHAPE) as the name of one of your procedures... not a good practice, it could confuse Visual Basic and cause unpredictable results
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  4. #4
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    johnske, thank you I'll keep that in mind (always like to follow good practice coding )

    Killian, I think we both know where this is going
    Thanks for all the shape values good stuff

    I realized that I made a mistake. That shape type 6 had a text box WITHIN the shape... my bad. So I named the text box "txtAddress" and the following code worked:

    [VBA]
    Sub SHAPE()
    Dim oShape As Object
    Set oShape = ActiveSheet.Shapes("txtAddress")
    oShape.TextFrame.Characters.Text = "Joe"
    End Sub[/VBA]
    Thanks for the help guys!

    Hey Killian, have anymore good info like that about shapes???




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  5. #5
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    You're welcome...
    Nothing springs to mind regarding shapes - I don't work with them that much in Excel - however I find the best way to get to the details on anything is to hit F2 and dig around in the object model.
    K :-)

  6. #6
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Thanks Killian, I'll remember the Object Model for reference next time I have to deal with this rediculousness.




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

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