Setting table properties in code

T

tedmi

A table pasted from the clipboard into an empty doc needs to have its
properties set (it was copied to the clipboard by Excel). However, statements
like this are failing:
Selection.Tables(1).Rows.AllowBreakAcrossPages = False
The error message is 4608, Value out of Range.
?Selection.Tables.Count shows 1 in the immediate window,
and ?Selection.Tables(1).Rows.AllowBreakAcrossPages displays -1

If I create a table by hand, and run the code, it works - but not on the
table imported from Excel.

Here's how I built it. Opened an existing .dot file, created a table by
hand, recorded a macro that sets the properties, deleted the table.
But when I open a doc from this dot, and paste the Excel-created table, no
joy.

Any clues? Thanks.
 
T

tedmi

Found the solution: The pasted table exceeded Word's width limit of 22
inches. No warning, and table properties could be set via the UI, but some
operations in code would fail. I limited the width by letting the text wrap
in the rightmost column in Excel.
 

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