PDA

View Full Version : Solved: Still hate shapes...



malik641
11-07-2005, 09:17 PM
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:

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 Yet no luck :banghead:

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

.......

God I hate shapes....:mkay

Killian
11-08-2005, 04:43 AM
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 :devil:
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 :whistle: 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

johnske
11-08-2005, 04:58 AM
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 :thumb

malik641
11-08-2005, 07:00 AM
johnske, thank you I'll keep that in mind (always like to follow good practice coding :yes )

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

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


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

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

Killian
11-08-2005, 08:15 AM
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.

malik641
11-08-2005, 08:59 AM
Thanks Killian, I'll remember the Object Model for reference next time I have to deal with this rediculousness.