Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Text Function change output text color? epiekarc Excel Discussion (Misc queries) 1 December 31st 08 02:58 AM
change the text in the legend of a chart w/o changing pivot text msp Charts and Charting in Excel 2 December 17th 08 08:53 PM
How can I change text to proper text in multiple cells. bethye99 Excel Discussion (Misc queries) 1 January 10th 06 06:17 PM
Change of text or background color doesn't change on the screen. Susan Excel Discussion (Misc queries) 5 July 29th 05 07:18 PM
HOW TO CHANGE BAHTTEXT (THAI TEXT) TO ENGLISH TEXT IN EXCEL BASHIR Excel Worksheet Functions 0 March 29th 05 12:49 PM


All times are GMT +1. The time now is 02:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"