Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello.
I know about "Fit Columns To Data" function in the straight table context menu.
But is there a macro function for that?
Thank you.
You can use something like this:
set mybox = ActiveDocument.ActiveSheet.CreateTableBox
mybox.AddField "Class"
mybox.AddField "ClassComment"
set tbp = mybox.GetProperties
tbp.Layout.ColLayouts.Item(0).ColWidth = 200
tbp.Layout.ColLayouts.Item(1).ColWidth = 400
mybox.SetProperties tbp
Instead of 200 and 400 you can calculate a maximum length for the columns.
No
I want to have an autofit depending on length of data in fields just like the manual "Fit Columns To Data" function.
UPD: Ah, sorry. You mean to calculate the maximum length before formating table layout. Yes, thank you, I'll try this.
But I hoped there is simplier way 😞