PowerPoint 2002 - Charts disapear when using VisualBasic SaveAs and Export routines!

  • Thread starter Thread starter kw
  • Start date Start date
K

kw

I am developing an application which indexes powerpoint text and publishes
the slides to the web. As part of this process, we convert all slides to
Jpeg. This works fine except when we get to certain bar charts which have
been inserted into powerpoint. These are the charts which use an Excel
datagrid to input data. What we are doing is pretty simple - here is a code
fragment.

###
ppt = Server.CreateObject("PowerPoint.Application")

ppt.Presentations.Open("c:\" & filename,
Microsoft.Office.Core.MsoTriState.msoTrue,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse)

oPres = ppt.Presentations.Item(1)

oPres.SaveAs(path & image_name, PpSaveAsFileType.ppSaveAsJPG,
Microsoft.Office.Core.MsoTriState.msoTrue)

###

The example above assumes the filename and path are specified as variables.
The result of the last line - oPres.SaveAs is a folder that contains all of
the slides and they all look fine, except the ones that should have charts,
do no.

Has anyone run into this and if so, is there a solution, either by way of
the ususal Microsoft bug patch, or a programming work around? Many Thanks in
advance.
 
So the slide exports ok but the chart on the slide disappears?
What happens if you export manually from PPT using File, Save As?
What happens if you manually ungroup the chart? Then export?
 
Right - the chart disappears.

If I do it manually in PPT, it works, so there is a step I am missing.

I got excited when you suggested ungrouping and I ungrouped a chart on my
test file and then ran it through my VB routine and it worked.

HOWEVER, I am having great difficulty figuring out how to ungroup. The
following two different tests never evaluate TRUE even though there is a
Microsoft Chart in the slide. Both of the statements below have been tested
within a loop that iterates through all the shapes on a given slide.

If oShp.Type = Microsoft.Office.Core.MsoShapeType.Group Then

oShp.Ungroup()

End If



If oShp.Type = Microsoft.Office.Core.MsoShapeType.msoChart Then

oShp.Ungroup()

End If



I also tried a few other types such as OLE without success. Anyone have any
ideas out there? THanks in advance.
 
Right - the chart disappears.

If I do it manually in PPT, it works, so there is a step I am missing.

One thing you might try instead of SaveAs is the .Slide.Export method, which
gives you a lot more control over things.
I got excited when you suggested ungrouping and I ungrouped a chart on my
test file and then ran it through my VB routine and it worked.

HOWEVER, I am having great difficulty figuring out how to ungroup. The
following two different tests never evaluate TRUE even though there is a
Microsoft Chart in the slide. Both of the statements below have been tested
within a loop that iterates through all the shapes on a given slide.

If oShp.Type = Microsoft.Office.Core.MsoShapeType.Group Then
oShp.Ungroup()
End If

If oShp.Type = Microsoft.Office.Core.MsoShapeType.msoChart Then
oShp.Ungroup()
End If

MSGraph charts aren't Group shapes or, oddly, msoChart shapes.

I'm not sure what the .Net constant would be, but you want to test for an
embedded OLE object and if found, test that MSGRAPH is part of its ProgID
string.

In VBA, that'd be along the lines of:

With oShp
if .Type = msoEmbeddedOLEObject Then
If Instr(Ucase(.OLEFormat.ProgID), "MSGRAPH") > 0 Then
oShp.Ungroup
End if
End If
End with

If it's an Excel chart, the test is a bit different; I don't have it handy to
mind right now.
 
Back
Top