"Shape.Table Object doesn't exist" error when using Automation

G

Guest

All,

I'm struggling with a very vexing problem.

I'm building an application that generates PowerPoint presentations from
data coming from a database.

I start with a PowerPoint "template" that has a couple of macros - I pass
the data to those macros, and they place the data into the appropriate shapes
in the PPT.

One of the slides contains a table. The macro is supposed to work like this:
if there's enough room in the table, place the data into the table. If there
are more rows of data than will fit, copy the slide (several times if
necessary), until there are enough tables to fit all the data. Then place the
data.

This works great, but only about 3/4 of the time!

In other words, if I run the process - everything works great. If I run it
several times in a row, everything works great. But every once in a while, I
get an error from that macro that says "Shape.Table Object doesn't exist"

It's as though, when I duplicate the slide that contains the table, the new
slide SOMETIMES doesn't contain that table.

This happens even if i use the exact same data every time, so it's not
related to any particular piece of data.

Any idea why this might be the case?

Many thanks in advance!

Cheers,
Matt Stuehler
 
S

Steve Rindsberg

Mstuehler said:
All,

I'm struggling with a very vexing problem.

I'm building an application that generates PowerPoint presentations from
data coming from a database.

I start with a PowerPoint "template" that has a couple of macros - I pass
the data to those macros, and they place the data into the appropriate shapes
in the PPT.

One of the slides contains a table. The macro is supposed to work like this:
if there's enough room in the table, place the data into the table. If there
are more rows of data than will fit, copy the slide (several times if
necessary), until there are enough tables to fit all the data. Then place the
data.

This works great, but only about 3/4 of the time!

In other words, if I run the process - everything works great. If I run it
several times in a row, everything works great. But every once in a while, I
get an error from that macro that says "Shape.Table Object doesn't exist"

It's as though, when I duplicate the slide that contains the table, the new
slide SOMETIMES doesn't contain that table.

This happens even if i use the exact same data every time, so it's not
related to any particular piece of data.

Any idea why this might be the case?

Are you perhaps running this in a virtual machine under VPC or the like?
Sometimes it can introduce apparent timing problems that result in this kind of
thing.

Adding a few DoEvents after duplicating the slide may help if so.
 
S

Shyam Pillai

Does it say, 'This shape does not have a table'? Is your shape reference
accurate?
 
G

Guest

Shyam and Steve,

Many thanks for your responses.

The exact error I get is "Shape.Table Object doesn't exist"

However, I don't think this can be caused by an incorrect reference, for two
reasons:

1. The script functions 3 out of 4 times i run it, even when running with
the exact same data.

2. The original slide has a table on it, that's been named "table". However,
i've noticed that when i duplicate that slide, that the table on the new
slide doesn't keep the name - e.g., the table name on the duplicate slide is
"Group ##". So, I use this code to get a reference to the table:
--------------------
For each oShape in oSlide
if oShape.hasTable Then Exit For
Next

With (oShape.Table)
...
------------------------

Since the new slide only has one table, i think this should always work.

I'm only guessing, but it LOOKS like a "timing" issue - that is, there's a
lag between when PPT duplicates the slide, a when PPT realizes there's a
table on the slide. So, SOMETIMES, that For Each loop doesn't find a table,
and I get that error.

Again, many thanks for your help.

Cheers,
Matt
 

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