I have an Excel Chart object (Excel.Chart.8) in MS Word document. I'm trying
to access the chart. But I sometimes get an error. The following is my
program.

Dim i As Integer
Dim strProgId As String

For i = 1 To gwdDoc.InlineShapes.Count
With gwdDoc.InlineShapes(i)
If .Type = wdInlineShapeEmbeddedOLEObject Then
'wdInlineShapeEmbeddedOLEObject=1
strProgId = .OLEFormat.ProgId 'I sometimes get an error
If Left(strProgId, 11) = "Excel.Chart" Then
.OLEFormat.Activate
Set objOLE = .OLEFormat
Exit Function
End If
End If
End If
End With
Next i


I debuged the code. I can not somtetimes access the property ProgId, and get
the error message. "No ProgID is available for this object."
Sometimes it is OK. sometimes it is error. Very strange. I accessed the
property ClassType, and I get the value "Excel.Chart.8".

Any idea?

Thanks advance,
Liu Jianzhong

Re: No ProgID is available for this object. by Jean-Guy

Jean-Guy
Mon Nov 26 13:09:48 PST 2007

ExcelReport was telling us:
ExcelReport nous racontait que :

> I have an Excel Chart object (Excel.Chart.8) in MS Word document. I'm
> trying to access the chart. But I sometimes get an error. The
> following is my program.
>
> Dim i As Integer
> Dim strProgId As String
>
> For i = 1 To gwdDoc.InlineShapes.Count
> With gwdDoc.InlineShapes(i)
> If .Type = wdInlineShapeEmbeddedOLEObject Then
> 'wdInlineShapeEmbeddedOLEObject=1
> strProgId = .OLEFormat.ProgId 'I sometimes get an error
> If Left(strProgId, 11) = "Excel.Chart" Then
> .OLEFormat.Activate
> Set objOLE = .OLEFormat
> Exit Function
> End If
> End If
> End If
> End With
> Next i
>
>
> I debuged the code. I can not somtetimes access the property ProgId,
> and get the error message. "No ProgID is available for this object."
> Sometimes it is OK. sometimes it is error. Very strange. I accessed
> the property ClassType, and I get the value "Excel.Chart.8".
>
> Any idea?

This probably means that the object the code is processing does not have a
ProgID... Why don't you use error trapping to bypass those objects?

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org