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 (i.e.
where shape.type = msoTable) to a particular style.
The formatting code works ok the first time it's called on a shape, but
after the code has finished attempts to reference the Line or Fill properties
of that cell's shape from both vb.net and vba raise errors. vb.net throws a
"System.Runtime.InteropServices.COMException (0x800A01A8): Exception from
HRESULT: 0x800A01A8." exception and vba raises a "Runtime Error 424: Object
required" error.
The vb.net code segment I'm currently using is as follows:
' format the cell's fill
cellFill = cell.Shape.Fill
If bShowFill Then
' fillForeColor and fillBackColor are System.Drawing.Color objects
defined earlier in the code
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 = 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 = 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 (although
the references are broken again after it finishes). I get the same thing if I
save and close the file then re-open it.
It seems to me that vb.net is somehow breaking PowerPoint's internal object
references and it's only recovering when I cut&paste or close&open. For
reference, I didn't have this problem with the original vba add-in.
If anyone knows what's going wrong here it would really help me out. I can
post more code if needed.
Regards,
Mike
I've recently upgraded a VBA addin for PowerPoint to a
IDTExtensibility2-based vb.net 2003 project that formats Table shapes (i.e.
where shape.type = msoTable) to a particular style.
The formatting code works ok the first time it's called on a shape, but
after the code has finished attempts to reference the Line or Fill properties
of that cell's shape from both vb.net and vba raise errors. vb.net throws a
"System.Runtime.InteropServices.COMException (0x800A01A8): Exception from
HRESULT: 0x800A01A8." exception and vba raises a "Runtime Error 424: Object
required" error.
The vb.net code segment I'm currently using is as follows:
' format the cell's fill
cellFill = cell.Shape.Fill
If bShowFill Then
' fillForeColor and fillBackColor are System.Drawing.Color objects
defined earlier in the code
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 = 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 = 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 (although
the references are broken again after it finishes). I get the same thing if I
save and close the file then re-open it.
It seems to me that vb.net is somehow breaking PowerPoint's internal object
references and it's only recovering when I cut&paste or close&open. For
reference, I didn't have this problem with the original vba add-in.
If anyone knows what's going wrong here it would really help me out. I can
post more code if needed.
Regards,
Mike