none
Generating a text file in a certain format from an Excel worksheet using VBA RRS feed

  • Question

  • The attached file "Temp.xlsm" has been provided to me. I need to generate two files from it - 1) csv 2) a text file in  a certain format. It should basically look liked the attached file "InFile.txt" which is an input file for a modelling tool. The arrays and struct strings need to be within brackets and it only contains inputs. Outputs don't need to be generated.
    With the code in "Temp.xlsm" so far I have been able to generate attached file "Temp.txt". The only missing bit is the formatting of arrays and structures.
    Basically for row7 in "temp.xls" , if it is
    Xls               -  In
    Struct_Start -   (
    Array_Start  -   (
    Array_and_Struct_Start - ((
    Struct_End - )
    Array_End - )
    Array_and_Struct_End - ))
    and members within these need to be separated by commas. Can anyone please help?

    ===Temp.xlsm===

    Test   Package CalculationPackage::Run_Calculation
    Version No 1.1
    Export to Test Harness
    IO Name FlashOff A[0].data A[0].SoundAlarm A[1].data A[1].SoundAlarm A[2].data A[2].SoundAlarm A[3].data A[3].SoundAlarm B[0].data B[1].data B[2].data B[3].data
    IO Type Input Input Input Input Input Input Input Input Input Output Output Output Output
    Array/Structure Array_and_Struct_Start Struct_End Struct_Start Struct_End Struct_Start Struct_End Struct_Start Array_and_Struct_End
    Tolerance
    Tolerance Type None/%/abs
    TestCase Comment (Mandatory *this column   musn't be  left blank*)
    1 This isjust a trial FALSE 0 FALSE 1 FALSE 2 FALSE 3 FALSE 5 6 7 8
    2 This isjust a trial FALSE 1 FALSE 2 FALSE 3 FALSE 4 FALSE 6 7 8 9
    3 This isjust a trial FALSE 2 FALSE 3 FALSE 4 FALSE 5 FALSE 7 8 9 10
    4 This isjust a trial FALSE 3 FALSE 4 FALSE 5 FALSE 6 FALSE 8 9 10 11
    5 This isjust a trial TRUE 0 FALSE 0 FALSE 0 FALSE 0 FALSE 8 9 10 11
    6 No comment TRUE 1 FALSE 1 FALSE 1 FALSE 1 FALSE 8 9 10 11

    ==InFile.txt===

    #$VERSION=2
    CalculationPackage::RunCalculation/FlashOff CalculationPackage::RunCalculation/A
    false ((0, false), (1, false), (2, false), (3, false))
    false ((0, false), (1, false), (2, false), (3, false))
    false ((0, false), (1, false), (2, false), (3, false))
    false ((0, false), (1, false), (2, false), (3, false))
    false ((0, false), (1, false), (2, false), (3, false))
    false ((0, false), (1, false), (2, false), (3, false))
    false ((0, false), (1, false), (2, false), (3, false))
    false ((0, false), (1, false), (2, false), (3, false))
    true ((0, false), (1, false), (2, false), (3, false))
    #
    #xyz  04/03/2014  15:16:59
    #
    #   xls Version No: 1.1

    ==Temp.txt==

    #$VERSION=2
    CalculationPackage::Run_Calculation/FlashOff CalculationPackage::Run_Calculation/A[0].data CalculationPackage::Run_Calculation/A[0].SoundAlarm CalculationPackage::Run_Calculation/A[1].data CalculationPackage::Run_Calculation/A[1].SoundAlarm CalculationPackage::Run_Calculation/A[2].data CalculationPackage::Run_Calculation/A[2].SoundAlarm CalculationPackage::Run_Calculation/A[3].data CalculationPackage::Run_Calculation/A[3].SoundAlarm
    False 0 False 1 False 2 False 3 False
    False 1 False 2 False 3 False 4 False
    False 2 False 3 False 4 False 5 False
    False 3 False 4 False 5 False 6 False
    True 0 False 0 False 0 False 0 False
    True 1 False 1 False 1 False 1 False
    #
    #xyz  04/03/2014  16:12:42
    #
    #   xls Version No: 1.1

    Tuesday, March 4, 2014 9:10 PM