Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to change Text
Hi,
This one is driving me crazy :-) While i can change the displayed Text in a shape object, i cannot change it when the shape is grouped: Excel returns the error "Unable to ..." (it accept the property but cannot access it). On the other hand, the methods to delete the text, access/change its font, or Fill color still work fine on that individual grouped shape. I tried all the methods in the Sub bellow (assumes 2 shapes in activesheet, the second one has text, and they are grouped). Any idea, pleeeeease? '------------------------------------- Sub ChangeRect2() Dim s As Shape Dim tf As TextFrame Dim str As String Set s = ActiveSheet.Shapes(1).GroupItems(2) 'shape 2 Set tf = s.TextFrame With tf str = .Characters().Text '-------WORKS FINE------------------ 'Set strikethrough .Characters().Font.Strikethrough = True 'Delete portion of the text .Characters(1, 2).Delete '------- FAILS ----------------- 'Inserting characters .Characters(1).Insert "hihihi" .Characters(1, 2).Insert "hi" 'Changing the text directly .Characters.Text = "HHHH" .Characters(1, 2).Text = "HH" 'Chanhing the text through the OLEObject s.OLEFormat.Object.Text = "aaa" s.OLEFormat.Object.Caption = "aaa" MsgBox s.Name & " = " & TypeName(s.OLEFormat.Object) End With End Sub '-------------------------------------------------- One more thing: ungroup/regroup the shapes is not a good solution in my situation because i would have to do that hundreds of thousands of times. -- Regards, SĂ©bastien PS: Rating a post as €śthe answer€ť helps searches and gives the answerer credit for their contribution. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to change Text
I'm not for sure, but I think your problem is that you're not specifying which object in the group to access. Try below: dim s as oleobject for i = 1 to ??? set s = sheet1.oleobjects("TypeOfObject" & i) ' Where the type of object is the name of your shape if s.name = blah then s.object.text = "aaa" end if *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can Text Function change output text color? | Excel Discussion (Misc queries) | |||
change the text in the legend of a chart w/o changing pivot text | Charts and Charting in Excel | |||
How can I change text to proper text in multiple cells. | Excel Discussion (Misc queries) | |||
Change of text or background color doesn't change on the screen. | Excel Discussion (Misc queries) | |||
HOW TO CHANGE BAHTTEXT (THAI TEXT) TO ENGLISH TEXT IN EXCEL | Excel Worksheet Functions |