Shape.Table goes missing when filling Powerpoint table with Excel

G

Glenn H

Hi,

I am working on an application that uses data in Excel to create Powerpoint
slides based on an existing Poiwerpoint template.

I am running into an error that occurs only under certain conditions. The
error occurs when the VBA tries to take data from Excel and put it into a
Powerpoint table. The error text is:

"Shape.Table : Invalid Request. This shape does not have a table."

The conditions under which the error occurs are:

1. I have already run the code once (it always runs correctly the first time).
2. I have not closed Powerpoint since I previously ran the code (closing and
restarting Powerpoint keeps the error from occuring, even though the VBA is
actually in an Excel workbook and I have not restarted Excel).

The data does not seem to be the problem, as I can use the same data for the
first run and get the correct output, then use it again on the second run,
and get the error.

The odd thing is that if I run the code in debug mode, I can click "Run" in
the VB Editor after getting the error, and the code completes correctly -
even though I changed nothing.

Here is the offending section of code:

=======================================
For iColumn = 1 To .Shapes(j).Table.Columns.Count
If iColumn > .Shapes(j).Table.Columns.Count Then
Exit For

iRow = 1
Do While iRow <= .Shapes(j).Table.Rows.Count
iReturnValue =
replace_ppt_shape(.Shapes(j).Table.Cell(iRow, iColumn).Shape,
dFieldsToReplace, sNotFound, True)

If iReturnValue = 0 Then
' Nothing was replaced
iRow = iRow + 1
ElseIf iReturnValue = 1 Then
' Text was replaced
.Shapes(j).Table.Rows(iRow).Height = 12
iRow = iRow + 1
ElseIf iReturnValue = 2 Then
' N/A was found - delete the row
.Shapes(j).Table.Rows(iRow).Delete
ElseIf iReturnValue = 3 Then
' N/C was found - delete the column
.Shapes(j).Table.Columns(iColumn).Delete
End If
Loop
Next
==============================

Glenn Hollister
 

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