Greetings all,
I have a macro in Excel that creates a Word document and inserts various objects from Excel to the Word document. Everything is working as I want except one thing.
In several instances, I am copying an Excel range and pasting into the Word document as a table. The paste is performed at a specific bookmark in the Word document. In my macro, I am trying to go back to two specific tables and set the column widths to the same for each of those two tables. This is how I would like the tables to come out ...
After running my macro, this is how the tables appear ...
I have tried to add some code to my macro, which seems to execute without any errors, however, there is no change in my tables appearance ...
What am I doing wrong?
Any help is greatly appreciated.
Steve
I have a macro in Excel that creates a Word document and inserts various objects from Excel to the Word document. Everything is working as I want except one thing.
In several instances, I am copying an Excel range and pasting into the Word document as a table. The paste is performed at a specific bookmark in the Word document. In my macro, I am trying to go back to two specific tables and set the column widths to the same for each of those two tables. This is how I would like the tables to come out ...
After running my macro, this is how the tables appear ...
I have tried to add some code to my macro, which seems to execute without any errors, however, there is no change in my tables appearance ...
VBA Code:
:
:
' Adjust Column Widths on Reserve Component Maint Schedule Tables
With newWord.Tables(2) ' Table(2) should be the Completed Schedule Table
.PreferredWidthType = wdPreferredWidthPercent
.Columns(1).SetWidth ColumnWidth:=10
.Columns(2).SetWidth ColumnWidth:=13
.Columns(3).SetWidth ColumnWidth:=13
.Columns(4).SetWidth ColumnWidth:=13
.Columns(5).SetWidth ColumnWidth:=8
.Columns(6).SetWidth ColumnWidth:=13
.Columns(7).SetWidth ColumnWidth:=30
End With
With newWord.Tables(3) ' Table(3) should be the Maintenance Schedule table
.PreferredWidthType = wdPreferredWidthPercent
.Columns(1).SetWidth ColumnWidth:=10
.Columns(2).SetWidth ColumnWidth:=13
.Columns(3).SetWidth ColumnWidth:=13
.Columns(4).SetWidth ColumnWidth:=13
.Columns(5).SetWidth ColumnWidth:=8
.Columns(6).SetWidth ColumnWidth:=13
.Columns(7).SetWidth ColumnWidth:=30
End With
:
:
What am I doing wrong?
Any help is greatly appreciated.
Steve