How to save .xls file using TestStand at a predefined location

I wanted to write a test case using TestStand without using LabVIEW VIs. My requirements are -

1. Through TestStand, read "RLOC" and "Voltage" column/information from some Input.xls template file and create respective local array variables accordingly within the Teststand sequence file.

2. Launch a new worksheet which will gather the test results by using the local array variables (created in step 1) as input. Pass/Fail criteria will be implemented based on the values read from the engine ECM.

3. Lets call the new worksheet as "Results.xls" and it should get saved at a pre-defined location.

Out of above mentioned points, I am able to implement point # 2, but I am still not able to figure out "how can I Read the value from Input.xls template file", and "how can I save the Results.xls file at a predefined path".

Please have a look at the attached sequence. I have currently hard coded Locals.RLOC[] and Locals.[x][0], but eventually I want this info to get populated from Input.xls file.

Also, at step 12/14, I am trying to use the step "Save Excel", but I don't think its the correct step. It is asking for Filename (Optional) as input, and even though I have mentioned "Results.xls", while saving the file its getting saved by name as Book1.xla, Book2.xls.

Can you please suggest any step wherein I can mention the path where the file will get saved with the name Results.xls?

Re: How to save .xls file using TestStand at a predefined location

I am using Locals.Results_Filename and and getting the path of file where I want to save the report. I am using this Local variable as an input to "SaveAs" step, to send the Filename (optional) value.

In this case, the value stored in the Locals.Results_Filename is "D:\\Niraj\\temp_123\\Loopback_Test_123_6-11-2012_1_42_.xlsx", but I am getting following run time error.

Error, An error occurred calling 'SaveAs' in '_Workbook' of 'Microsoft Excel 12.0 Object Library' The file could not be accessed. Try one of the following: • Make sure the specified folder exists. • Make sure the folder that contains the file is not read-only. • Make sure the file name does not contain any of the following characters: < > ? [ ] : | or * • Make sure the file/path name doesn't contain more than 218 characters. Source: Microsoft Office Excel [Error Code: -2146827284, User-defined error code.]

Method II:

But, if I replace the Locals.Results_Filename and instead directly use "D:\\Niraj\\temp_123\\Loopback_Test_123_6-11-2012_1_42_.xlsx", then the same SaveAs step works fine without giving Run Time Error, and my test report is getting saved properly.

But, since I can not keep the Filename as fixed, instead I want some way where I can use the Locals.Results_Filename to define the file location.

Logically both Method I and Method II are the same, but I am not able to understand why it is giving run time error for MEthod I.

Re: How to save .xls file using TestStand at a predefined location

It works and now I am more concerned about when to use "\" and when to use "\\". I remember I used to have issues when using "\" in the variable while using it to store the file path. Anyways, I will remove the step where I was converting each "\" and replacing it with "\\".

That solves my one of the issues. Thanks for that.

One issue which still is open is, can you tell me how can I read the value from xls file using ActiveX commands? Please refer my first post in this thread.

I have currently hard coded Locals.RLOC[] and Locals.[x][0], but eventually I want this info to get populated from Input.xls file.

Please suggest some way to fetch the info from .xlsx file and use it in TestStand using ActiveX command.