Forum Discussion

sachinmailar's avatar
sachinmailar
Occasional Visitor
9 years ago

how to move table variables between project suites?

I have a couple of very big table variables of size 24 * 24 in one project suite and i need to find a way to get them into another project suite. I wanted to know if there was any way other than manually creating duplicate tables in the new project suite.

 

Thanks,

Sachin Mailar

sachin.mailar@sabre.com

1 Reply

  • dmiscannon's avatar
    dmiscannon
    Frequent Contributor

    TC does not have a mechanism to move Table variables between project suites that I am aware of. Is there a reason you are using a Table variable instead of reading your data from a CSV or Excel file? 

     

    You can write a script to read your existing Table variable into an Excel file if you choose to modify your scripts to use Excel. At least you wouldn't have to recreate the table. The code below does work for me for this. Good luck.

     

    Sub Table2Excel()

     

    Dim FSO, objExcel, objWorkbook, objSheet

    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set objExcel = CreateObject("Excel.Application")
    fp = "C:\MyFile.xlsx" ' Create a blank Excel file and save it. Enter the path of the file here.
    Set objWorkbook = objExcel.Workbooks.Open(fp)
    Set objSheet = objExcel.ActiveWorkbook.WorkSheets("Sheet1")

    Call Project.Variables.MyTable.Iterator.Reset 'Modify all of the Project.Variables lines to use your table
    'variable and variable level
    cc = Project.Variables.MyTable.ColumnCount
    rc = Project.Variables.MyTable.RowCount

     

    ' table column headers
    For j = 0 to cc - 1
      Call Log.Message(Project.Variables.MyTable.ColumnName(j))
      i = j + 1
      objWorkbook.WorkSheets("Sheet1").cells(1,i).Value = Project.Variables.MyTable.ColumnName(j)
    Next
    objWorkbook.Save

     

    ' table contents (by row, by column)
    For i = 0 to rc - 1
      r = i + 2
      For j = 0 to cc - 1
        c = j + 1
        Call Log.Message(Project.Variables.MyTable.Iterator(j))
        objWorkbook.WorkSheets("Sheet1").cells(r,c).Value = Project.Variables.MyTable.Iterator(j)
      Next
      Call Project.Variables.MyTable.Iterator.Next
    Next

     

    objWorkbook.Save
    objExcel.Quit

     

    End Sub