Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2007

Tip: Looking for answers? Try searching our database.

How to retrieve text from the textframe of an oval shape in Excel?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg M - 18 Dec 2007 13:58 GMT
It's straightforward to set text in the textframe of a shape using the
characters method but how can you retrieve the text? I've tried using text,
characters.caption and characters.text, and I've tried creating a characters
object and setting it from the characters method - nothing works. It looks
like a hole in the object model.
Dave Peterson - 18 Dec 2007 14:58 GMT
Option Explicit
Sub testme()
   Dim myOval As Oval
   Dim myStr As String
   
   Set myOval = Worksheets("sheet1").Ovals("Oval 1")
   
   myStr = myOval.Caption
   MsgBox myStr
End Sub

If you wanted to go through the Shapes collection:

Option Explicit
Sub testme2()
   Dim myShape As Shape
   Dim myStr As String
   
   Set myShape = Worksheets("sheet1").Shapes("Oval 1")
   
   myStr = myShape.DrawingObject.Caption
   MsgBox myStr
End Sub

> It's straightforward to set text in the textframe of a shape using the
> characters method but how can you retrieve the text? I've tried using text,
> characters.caption and characters.text, and I've tried creating a characters
> object and setting it from the characters method - nothing works. It looks
> like a hole in the object model.

Signature

Dave Peterson

Greg M - 18 Dec 2007 15:10 GMT
Thanks - this works perfectly. I could have spent forever not finding out
that you have to use a different object to read and write the same property!
Greg McCormick

> It's straightforward to set text in the textframe of a shape using the
> characters method but how can you retrieve the text? I've tried using text,
> characters.caption and characters.text, and I've tried creating a characters
> object and setting it from the characters method - nothing works. It looks
> like a hole in the object model.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.