Copying Excel table to Word, with Formatting

S

Squeff

I have an application that builds a nice looking table in Excel. The
end-user wants this to be as Word table, instead.

The spreadsheet has 10 columns (all equal width), although the columns
are merged in some rows.

I have a VBA routine (in Excel) that copies the spreadsheet and pastes
it into Word.

It looks good, but is too wide to fit on the page and it resizes the
columns inappropriately, so I issue this command
appWD.Selection.Tables(1).AutoFitBehavior (wdAutoFitWindow)
to (at least) make it fit on the page. However, this resizes the
columns in a way different than I want them.

I'd like to be able to have my paste use the exact same relative
columns widths as the source.

I've tried
appWD.Selection.Tables(1).Columns.Width = 44.25
but this doesn't work because I have merged cells. I can't specify a
column index, because I then get a message that it can't refer to
specific column indexes because of the merged cells.

The end result has to be a normal Word table, so I can't make it a
graphic. I can't have Excel save as an RTF, because this strips a
good deal of my formatting.

Any ideas of how I can end up with an exact copy of my Excel
spreadsheet as a Word table? All formatting, save for the widths, is
perfect.
 
S

Squeff

Why not embed the Excel file as an object in Word? Would that work?

Unfortunately not. The customer wants the resultant table to act like
a Word table, not an Excel table. This may seem a subtle thing, but
there are some key differences. For example, Word will nicely
autosize rows (even for merged cells), while Excel will not.
 

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