PDA

View Full Version : VBA ...Table resize to the Maximum width after delete table row



kpangfb0630
04-24-2019, 08:37 AM
Hi all,

I had a program that writing the report to MS Word from MS Access Marco. The MS Access references from a pre-defined template. The Word table is generated in run-time from the Access Macro. Therefore, all tables creation width/column sizing are generated in run-time.

First, the code calls the document to split the page into two columns.
Starting from left-handed size, the table is sizing to 3.55" with 3 columns (2.15", 0.7" and 0.7"), the 1st row contains the "header" text.
Then, the table row expanded line-by-line depending the size of the record row (The ancestor written in that way).
When the data is populated to the tables (saying there are 40 rows), the control returns to the 1st row and call the "word.selection.tables(1).row(1).delete" to remove the 1st row.

The code works fine under MS Office 2010.

However, when the MS office upgrade to 2013, the code in some occasions the table width is changed to 22" by when calling the "word.selection.tables(1).row(1).delete"

Below is the code that it creates the table on MS Word from Access Macro
objword.documents(1).Tables.Add <range>, <# of rows>, <# of columns>, wdWord9TableBehavior, wdAutoFitFixed


Any Suggestion? Thx : pray2:
Karl

macropod
04-24-2019, 03:11 PM
Show us the actual code you're using for both the creation & population of the table, plus the deletions.