Charts yet again

P

paul

Hi all!

This is the issue that I can not solve for a long time and I am hoping
someone has an answer. We are building an applilcation that is capable of
creating ms charts and output them in a different formats (excel, ppt, word).
Word is giving us lots of problems.
if I am generating several charts, i get MSGraph windows open for each and
every chart out there. Also it makes the word document visible, which is not
what we need at the point of generation. So my question is is there any way
to make the MSGraph run in the background, kind of hidden?

Cindy had suggested chart.Applicaiton.Quit, but that terminates the msword
and not msgraph.

Thanks in advance
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?cGF1bA==?=,
This is the issue that I can not solve for a long time and I am hoping
someone has an answer. We are building an applilcation that is capable of
creating ms charts and output them in a different formats (excel, ppt, word).
Word is giving us lots of problems.
if I am generating several charts, i get MSGraph windows open for each and
every chart out there. Also it makes the word document visible, which is not
what we need at the point of generation. So my question is is there any way
to make the MSGraph run in the background, kind of hidden?

Cindy had suggested chart.Applicaiton.Quit, but that terminates the msword
and not msgraph.
In this case, you're not referencing the correct application when you call the
..Quit command. Suppose you show us some of the code you're using to automate MS
Graph, if you're not figuring out which object variable to use for this...

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 :)
 
P

paul

Here is the sub

Sub AddChart(ByVal chartOptions As *.*.CChartOptions, ByVal presOptions
As *.*.CPresentationOptions) Implements IWord.addchart
Dim shp As Word.InlineShape
shp =
_wordDocument.Paragraphs.Item(paragraphCount()).Range.InlineShapes.AddOLEObject(ClassType:="MSGraph.Chart", LinkToFile:=Office.MsoTriState.msoFalse)
shp.Application.Visible = False
If chartOptions.Width <> -1 Then
shp.Width = chartOptions.Width
End If

CLogger.LogIf("Updating Chart Datasheet")
If (chartOptions.UpdateDataSheet(shp.OLEFormat.Object) <> True) Then
CLogger.Log("Chart " & _mrx.PageTabNumAttribute & " has no data
present. Check to make sure you are not hidding the entire chart",
CLogger.EntryType.Warning)
Return
End If
CLogger.LogIf("Updating Chart Options")

chartOptions.UpdateChart(shp.OLEFormat.Object)

If chartOptions.Width <> -1 Then
shp.Width = chartOptions.Width

End If

AddSection()
End Sub

I had to hide some code, my boss scans these forums too
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?cGF1bA==?=,
I had to hide some code
Well, what you show isn't enough, really, to pinpoint where
the problem is coming from. All I can say is:

Supposedly, somewhere you're doing an Activate on
"shp.OLEFormat.Object" and assigning it to an object
variable. Let's assume you're doing something like this
Set ochart = shp.OLEFormat.Object
ochart.Activate 'or .DoVerb

At some point, you need to: ochart.Application.Quit

But note you need to do that for EVERY time you activate
the object. I notice you pass shp.OLEFormat.Object to
various functions, in this code. Since I don't know what
the functions do, it's hard to say, but you have to watch
that.

A better design might be to declare an object variable in
this proc and assign it to the object. Maybe even as a
global variable for the module or even the project, so that
you can better track the object pointers.

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