Post by Ali Ihsan YuksekdagHi,
I've added multiple columns to multiple tables using vbscript. All of them are added at end of the table. So for so good. One of these fields needs to be placed as first column of the table.
Does any one know how to move a column in position using vbscript.
Thanks
Ali Ihsan
Hi, Ali. Here's a little scrikpt that illustrates how to create a new column in a certain position, and how to move an existing column to a new position.
Sean
'------------------------------------------------------------------------
Option Explicit
Dim oTable, oColumn
'Create a new table and give it a name
Set oTable = ActiveModel.Tables.CreateNew
oTable.Name = "Some Table"
oTable.SetNameToCode
'Create a Column and give it a name.
'The CreateNew method always appends a new object to the end of the collection.
Set oColumn = oTable.Columns.CreateNew
oColumn.Name = "Third Column"
oColumn.SetNameToCode
oColumn.DataType = "Integer"
'Create another Column and give it a name.
Set oColumn = oTable.Columns.CreateNew
oColumn.Name = "Second Column"
oColumn.SetNameToCode
oColumn.DataType = "Integer"
'Create a third column as the first column of the table.
'Note that the collection starts at position 0.
Set oColumn = oTable.Columns.CreateNewAt(0)
oColumn.Name = "First Column"
oColumn.SetNameToCode
oColumn.DataType = "Integer"
'Now move the last column in the table to the second position.
oTable.Columns.Move 2, 1