Autofit to window IF it extend across page

M

Mike

Hi folks,

I haven't any experience with Word VBA and just a little with Excel VBA.
However, despite the fact I don't have a clue what I'm doing, I've been able
to create an Excel macro to paste all of my nice formatted tables into a new
Word document. However...

As I anticipated, there are a few problems. The dimensions of my tables can
be of varying size. Some have only a a few columns and rows...and some have
many columns and rows. So I'm hoping someone knows how I could write some
code to be able to handle these particular circumstances. I think I have a
grasp on the logic I need, just not the code that would be needed to
accomplish the task.

It would go something like this (not actual code):

For each table in the active document

If the table is too wide for the page do this
Selection.Tables(1).AutoFitBehavior (wdAutoFitWindow)
End If

If the table is too long for the page
prompt user to indicate how many header rows there are
select those first rows and activate the 'header row repeat'
End If

"if the table fits on the page both horizontally and vertically--do nothing"

Next table

Any ideas?
 
Top