COMException while formatting PowerPoint shapes

M

Mike Clayton

Hi,

I've recently upgraded a VBA addin for PowerPoint to a
IDTExtensibility2-based vb.net 2003 project that formats Table shapes
(shape.type = msoTable) to a particular style.

The formatting code works ok, except that when I hide fills in individual
table cells using "cell.Shape.Fill.Visible = msoFalse" the vb.net version
seems to destroy the objects rather than just set the Visible property to
msoFalse. Later attempts to reference the Line or Fill properties of the
cell's shape then throw "System.Runtime.InteropServices.COMException
(0x800A01A8): Exception from HRESULT: 0x800A01A8." from vb.net or "Runtime
Error 424: Object required" from vba.

The code I'm currently using is as follows:

' format the cell fill
cellFill = cell.Shape.Fill
If bShowFill Then
' fillForeColor and fillBackColor are System.Drawing.Color objects
defined earlier
cellFill.ForeColor.RGB = RGB(fillForeColor.R, fillForeColor.G,
fillForeColor.B)
cellFill.BackColor.RGB = RGB(fillBackColor.R, fillBackColor.G,
fillBackColor.B)
cellFill.Transparency = sngFillTransparency
cellFill.Visible = Office.MsoTriState.msoTrue
Else
' this line seems to damage PowerPoint's reference to the fill object.
later
' attempts to read cell.shape.fill throw COMException 0x800A01A8.
cellFill.Visible = Office.MsoTriState.msoFalse
End If

The odd thing is that if I cut the shape from the slide and paste it back in
the same place then the cell.Shape.Line and cell.Shape.Fill object references
seem to get restored, and the formatting code runs without error.

If anyone knows what's going wrong here it would really help me out.

Regards,

Mike
 

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