Accessing Object property of a OLEFormat class

S

Smriti

When I try to access the object property of an OLEFormat,
it gives me an error saying "No such interface supported".
Here's a snippet of the code:

dim chart as graph.chart
dim oShape as word.shape
oShape = ShapeRange(1)
chart = ctype(oShape.OLEFormat.object,graph.chart)

Though I've seen a number of codes on the net which try to
do the same thing. Where am I going wrong ?
 
S

smriti

I figured out the solution. I need to do a Oleformat.edit()
before accessing the object property. Then it works.
 
H

haroldk

You can use this from Word to access the Chart
Sub foo()
Dim chart As Graph.chart
Dim oShape As Shape
'use this is the shape is selected
Set oShape = Selection.ShapeRange(1)
'use this when using the shapes collection
'Set oshape = ActiveDocument.Shapes(1)
oShape.Activate
Set chart = oShape.OLEFormat.Object
End Sub

By default a Chart is inserted in line with text so the actual object is an
InlineShape. But chart can be configured to be a Shape ( or float over the
text layer)
Also, take a look at this article
WD97: How to Edit an MS Graph Object Programmatically
http://support.microsoft.com/default.aspx?scid=kb;en-us;190239

Regards,
 
T

Tushar Mehta

As Harold pointed out, use of .object will let you access the chart
object itself. In addition to the MSKB article he indicated, you might
want to check a recent discussion: http://groups.google.com/groups?
threadm=MPG.1b7af18ce4f30bef98989b%40news-server

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
S

Smriti

Thanks a bunch.

-----Original Message-----
As Harold pointed out, use of .object will let you access the chart
object itself. In addition to the MSKB article he indicated, you might
want to check a recent discussion: http://groups.google.com/groups?
threadm=MPG.1b7af18ce4f30bef98989b%40news-server

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top