Since you are using beta/preview versions, you may have encountered a new bug. You should report it to Microsoft using the feedback facility in Word.
Different table columns size in two Word versions using PreferredWidthType and PreferredWidth in VBA
Lauro Colasanti
121
Reputation points
Hi,
I have the same VBA code to create a table and to set the size of its columns. The following:
Public Sub Test()
Dim objTabella As Table
Dim rng As Range
Set objTabella = ActiveDocument.Tables.Add(Selection.Range, NumRows:=1, NumColumns:=2, _
DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed)
With objTabella
.PreferredWidthType = wdPreferredWidthPercent
.PreferredWidth = 100
.Columns.PreferredWidthType = wdPreferredWidthPercent
.Columns(1).PreferredWidth = 5
.Columns(2).PreferredWidth = 95
End With
End Sub
In Microsoft® Word per Microsoft 365 MSO (Versione 2305 Build 16.0.16501.20074) a 64 bit (on Windows 10 Home),
I get, as expected:
But in Microsoft® Word per Microsoft 365 MSO (Versione 2306 Build 16.0.16529.20000) a 64 bit (on Windows 11 Pro), the whole table is no more 100%, what I get is the following:
For both versions I have the Beta Channel Insider.
Do you have any idea why?
Thanks, Lauro
Microsoft 365 and Office Development Other
4,375 questions
Microsoft 365 and Office Word For business Windows
1,938 questions
Accepted answer
-
Stefan Blom 2,861 Reputation points MVP Volunteer Moderator
2023-06-13T08:51:19.9433333+00:00