How to format Excel chart within Word

B

Bill Sturdevant

I am able to insert an Excel chart into a word document, but do not
understand how to set myself up to edit the chart: This is the code I am
trying to use. What do I need to do?

Dim oObject As Object
Dim oInlineShape As InlineShape
Set oObject =
Selection.InlineShapes.AddOLEObject(ClassType:="Excel.Chart.8", FileName:= _
"", LinkToFile:=False, DisplayAsIcon:=False)
Set oInlineShape = oObject.OLEFormat.oObject
With oObject
With .activesheet
'Format the embedded chart.
.ChartArea.Font.Size = 8
.HasLegend = False
.Application.Update
etc, etc.
 
E

Ed

Bill:

Just a stab in the dark , but I think you might have to actually open an
instance of Excel to avail yourself of the properties and methods for
formatting the chart. You might be better off asking this in the
microsoft.public.excel.programming newsgroup. If you do repeat it there,
send it to both of these groups if you can, and both sides can benefit from
the answers.

Ed
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?QmlsbCBTdHVyZGV2YW50?=,
I am able to insert an Excel chart into a word document, but do not
understand how to set myself up to edit the chart: This is the code I am
trying to use. What do I need to do?
You're very, very close :) Set up an object variable to contain the
.OLEFormat object. Then use .Activate or .DoVerb on that. Only after you've
done this should you make the assignment

Set oObject = oInlineShape.OLEFormat.Object (see the changes) I've made
below)

Dim of as Word.OLEFormat
Dim oObject As Object
Dim oInlineShape As Word.InlineShape
Set oInlineShape =
Selection.InlineShapes.AddOLEObject(ClassType:="Excel.Chart.8", FileName:= _
"", LinkToFile:=False, DisplayAsIcon:=False)
Set of = oInlineShape.OLEFormat
of.Activate
Set oObject = of.Object
With oObject
With .activesheet
'Format the embedded chart.
.ChartArea.Font.Size = 8
.HasLegend = False
.Application.Update
etc, etc.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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