Create and populate table in Word from Powerpoint

S

swordfish

Hello,

I would like to programatically create a table in word from ppt.

Here's my code (modified from the Word help file)

Dim appWD As Word.Application
Set appWD = New Word.Application
appWD.Documents.Add
appWD.Visible = True

Dim docActive As Document
Dim tblNew As Tables

Dim celTable As Cell
Dim intCount As Integer

Set docActive = appWD.ActiveDocument
Set tblNew =
Word.Application.ActiveDocument.Tables.Add(Word.Application.ActiveDocument.Range(Start:=0,
End:=0), NumRows:=3, NumColumns:=4, AutoFitBehavior:=wdAutoFitFixed)

Here's the error:

Run-time error '13':
Type mismatch

Not all defined objects are used. I have tried various ways of using the
objects and typing in the full object model reference. i.e. using
"Word.Application.ActiveDocument" instead of using "docActive =
appWD.ActiveDocument"

Thanks in advance for your help.
 
S

Steve Rindsberg

try

Dim tblNew As Table ' rather than Tables

Hello,

I would like to programatically create a table in word from ppt.

Here's my code (modified from the Word help file)

Dim appWD As Word.Application
Set appWD = New Word.Application
appWD.Documents.Add
appWD.Visible = True

Dim docActive As Document
Dim tblNew As Tables

Dim celTable As Cell
Dim intCount As Integer

Set docActive = appWD.ActiveDocument
Set tblNew =
Word.Application.ActiveDocument.Tables.Add(Word.Application.ActiveDocument.Range(Start:=0,
End:=0), NumRows:=3, NumColumns:=4, AutoFitBehavior:=wdAutoFitFixed)

Here's the error:

Run-time error '13':
Type mismatch

Not all defined objects are used. I have tried various ways of using the
objects and typing in the full object model reference. i.e. using
"Word.Application.ActiveDocument" instead of using "docActive =
appWD.ActiveDocument"

Thanks in advance for your help.
 
S

swordfish

Hi Steve,

I tried this, but I'm still getting the error. When I click "debug" this
line is highlighted:
Set tblNew =
Word.Application.ActiveDocument.Tables.Add(Word.Application.ActiveDocument.Range(Start:=0, End:=0), NumRows:=3, NumColumns:=4)

I get a table in the Word document to show up intermittently, but I always
get the error and my code stop running. Any other suggestions?

Thanks,
Alan
 
S

Steve Rindsberg

Hmm. PowerPoint has a Table shape too.
When I check this in PPT, Dim tblNew as Table gives me a PPT table.
And when I run that, I get a different error msg on the same line as you get
the Type MisMmatch error.

When I changed it to Dim tblNew as Word.Table, the code works here.
Give that a shot, report back in the morning. ;-)

Hi Steve,

I tried this, but I'm still getting the error. When I click "debug" this
line is highlighted:
Set tblNew =
Word.Application.ActiveDocument.Tables.Add(Word.Application.ActiveDocument.Rang
e(Start:=0, End:=0), NumRows:=3, NumColumns:=4)
I get a table in the Word document to show up intermittently, but I always
get the error and my code stop running. Any other suggestions?

Thanks,
Alan

Steve Rindsberg said:
try

Dim tblNew As Table ' rather than Tables
 
S

swordfish

Hi Steve,

I tried this and it works!! Thank you very much for your help. I noticed
you answer a lot of posts. Thank you for taking the time to respond. Your
expert help is invaluable.

Alan



Steve Rindsberg said:
Hmm. PowerPoint has a Table shape too.
When I check this in PPT, Dim tblNew as Table gives me a PPT table.
And when I run that, I get a different error msg on the same line as you get
the Type MisMmatch error.

When I changed it to Dim tblNew as Word.Table, the code works here.
Give that a shot, report back in the morning. ;-)

Hi Steve,

I tried this, but I'm still getting the error. When I click "debug" this
line is highlighted:
Set tblNew =
Word.Application.ActiveDocument.Tables.Add(Word.Application.ActiveDocument.Rang
e(Start:=0, End:=0), NumRows:=3, NumColumns:=4)
I get a table in the Word document to show up intermittently, but I always
get the error and my code stop running. Any other suggestions?

Thanks,
Alan
 
S

Steve Rindsberg

Hi Steve,

I tried this and it works!! Thank you very much for your help. I noticed
you answer a lot of posts. Thank you for taking the time to respond. Your
expert help is invaluable.

"Expert Help" and "Word" really shouldn't appear in any sentences I take part
in.<G>

Glad it worked for you!
 

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