table style

S

Stefano

can i copy all the style (font, width of the columns, position) from one
table to another using VBA?
thanks
 
P

Peter Hewett

Hi Stefano

The simple answer is not easily! You could do it but Word does not expose any
thing intricically for this purpose other than Table Styles in Word XP and
above .

The problem is is what does the code do if the source and destination tables
have a different number of columns or rows, or the first table is on a
portrait page and the second on a Landscape. Also you have table/cell borders
and shading to deal with. Wait, it gets worse! Each cell can contain multiple
paragraphs, each of these paragraphs may use a different styles or directly
applied formatting! And then each paragraph may contain a mixture of
different font families and bold/italic/upper case etc.

You get the idea. You could write some code, but for it to be robust it would
have to be able to make decisions about all of the above. You might put
together something simpler for a very specific purpose, but if you change the
table then you have to change the code - could be very skillset insensive.

HTH + Cheers - Peter
 
S

Stefano

ok you gave me the idea,
my tables (the source and the destination) are quite simple,
I use the source table to create the destination table, so both tables have
the same number of columns but differs on the number of rows
Each column has it's own style and each cell only contain simple text, no
shading or particular border.
I want to apply to the second table the positioning (x,y on the document),
the width and the font of each columns
The porpouse of this vba function is to create a table with data read from a
database and to allow a user to customize the layout of the document witout
changing the vba but only changing a .doc that my vba use as a model. I want
to use this code to print the content af a dbgrid in vb6.

is it possible to copy the font of one cell and apply it to another cell or
column?
can i get the positioning of a table in the document?
can i copy a row from one table and paste it in another table?

thanks
 
P

Peter Hewett

Hi Stefano

I'm not sure I understand exactly what you want or why you're copying table
formatting. if all you want to do is take data from table 1 and put it in
table 2, it seems you have two choices:

Why not allow the user to format Table 2 BEFORE you place any data in it.
That way you only deal with the formatting they've already set for that
table.

The other is to copy the first table and delete any rows/columns you don't
want.

Also check out this link for useful info on working with tables:

http://word.mvps.org/FAQs/TblsFldsFms/index.htm

HTH + Cheers - Peter
 

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