jorrebor
jorrebor

Reputation: 2232

Automatically format table in Word 2010

I have setup a database view. When users import the data from the view into Word 2010 it is formatted in the same way as being in the database, like so:

-------------------------------------------------------------
|workorder  |customer  |performed activity                  |
-------------------------------------------------------------
|12345      |Client foo|activity foo                        |
|67890      |Client bar|activity bar                        |
-------------------------------------------------------------

But I would like it to be displayed like so:

-------------------------------------------------------------
client name:        Client foo
workorder:          12345
performed activity: activity foo
-------------------------------------------------------------

-------------------------------------------------------------
client name:        Client bar
workorder:          6789
performed activity: activity bar
-------------------------------------------------------------

I need to perform a certain action sequence programmatically for each row. The number of rows is different each time the document is made. The number of fields and their position is always the same.

Upvotes: 1

Views: 3407

Answers (1)

Jan Werkhoven
Jan Werkhoven

Reputation: 2953

Use a Word template with a custom table styles set as default. Any table created in that document, manually or programmatically, will get the desired formating.

  1. Make a table (doesn't matter how big).
  2. Click within the table and you'll see 2 table-related tabs appear in the top Word toolbar.
  3. Click on the tab called 'Design'.
  4. Enlarge the default table styles dropdown by clicking on the right bottom arrow.
  5. Click on 'New Table Style ...' found at the bottom of the dropdown.
  6. Give your new table style a suitable name.
  7. Click on 'Format' in the left bottom and choose 'Borders and Shading'.
  8. Set the borders as you desire. In your case: click on each of the 3 icons left of the preview.
  9. Press OK in 'Borders and Shading' and OK 'New Table Style ...'.
  10. Your table style appears amongst the border styles in the top toolbar.
  11. Right click your newly created border style and choose 'Set as default'.
  12. Save the document as Word template (.dotx).
  13. Integrate the Word template in your macros.

I hope this helps.

*Performed on Microsoft Office Word 2007

Upvotes: 3

Related Questions