08-10-2017 01:59 PM
Hello,
Is there a way to programatically change the relative Width of a 2DTable in a VBS script? I can add columns by doing the following:
Call Report.NewLayout() Dim o2DTable Set o2DTable = Report.ActiveSheet.Objects.Add(eReportObject2DTable, "My2DTable") Call o2DTable.Columns.Add(e2DTableColumnChannel) Call o2DTable.Columns.Add(e2DTableColumnChannel) o2DTable.Columns(1).Channel.Reference = "g/c1" o2DTable.Columns(2).Channel.Reference = "g/c2"
However, I cannot change the width of the columns now and would like to. Is there a way to do this? Is there any method or way to change the widths of the columns in the VBS script? I will be doing this for different numbers of columns depending on the number of columns, so I cannot hard code it in.
Solved! Go to Solution.
08-11-2017 11:32 AM
Hi TheStrangeQuark,
Have you looked at this help document?
It has some information on how to set the 2D Table settings, plus a script example that may serve you as reference. Additionally, I am not completely sure on which width you were referring to but just as a further reference you might also be interested on the Grid properties, where you can set the width programmatically as well. You can find more on script properties by going to Help>Content and look for the Object: 2DTable Settings, where you can have a reference of the properties that can be changed through the script for the 2D Tables
I hope you could find this helpful!
Warm Regards,
08-11-2017 11:55 AM
I'm not seeing what I want in neither of those examples. If you create a table and then manually go to its properties, there is an option to give a relative width of each column of the whole table as a percent. So if you have 3 columns, you can do something like make the first 60% of the table, the second 10%, and the third 30%. After I populate the columns of a table, I was hoping to also programatically change how wide each column is since I want the columns to be different widths.
08-14-2017 03:37 PM
Hi there,
I believe you are looking for the property "RelativeColumnWidth"
Dim oMy2DTable, oMyPosition, oMyColumn1, oMyColumn2 Call Report.NewLayout() Set oMy2DTable = Report.ActiveSheet.Objects.Add(eReportObject2DTable,"My2DTable") Set oMyPosition = oMy2DTable.Position.ByBorder oMyPosition.Top = 30 oMyPosition.Bottom = 20 oMyPosition.Left = 20 oMyPosition.Right = 30 oMy2DTable.Settings.Header.Height = 20 Set oMyColumn1 = oMy2DTable.Columns.Add(e2DTableColumnChannel) oMyColumn1.Channel.Reference = "[1]/[1]" Set oMyColumn2 = oMy2DTable.Columns.Add(e2DTableColumnChannel) oMyColumn2.Channel.Reference = "[1]/[2]" oMyColumn2.Settings.RelativeColumnWidth = 2 Call Report.Refresh()
This was tricky to find. I searched the web and couldn't find it. I found it by seeing what the autocomplete could offer me.
I noticed that the DIAdem help lists all of the properties, objects and methods. You can find the Relative Column Width property page by starting at the DIAdem objects page and navigating to 2Dtablecolumn settings. That page has the RelativeColumnWidth property linked.