LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

copy

I'd posted this on the TestStand forum, and it was recommended I post this in the LabVIEW forumn - original post is at:

http://forums.ni.com/ni/board/message?board.id=330&message.id=21373

 

We are using TestStand 3.5 and LabVIEW 8.0 with the Microsoft Office Toolkit.  I'm trying to find a way to copy a range of cells from one file to another file using TestStand.  My test would have both files open, but I'm not sure how to copy cells from one file to another one.  I found several posts, but none seem to show me what I'm looking for - there were a couple that do copy/pasting, but they use a different way to reference the Excel file.  The toolkit generates a number to use as a reference to a file that is opened/created, but all the examples I've found on the forum use a different type of reference to indicate a file and I've not been able to figure out how to translate from one format to the other.

 

Ideally this would all be done by calling vi's directly from TestStand that already exist, although we can create new vi's if needed.

 

If there was some way to copy to the clipboard from file 1, then paste from the clipboard into file 2, that would work as well.  I'm thinking that might be the easiest way to do it, but I've not been able to figure that out yet. 

 

Anyone have any idea how I can do this?

 

Thanks!

0 Kudos
Message 1 of 6
(3,263 Views)

hi parkerfly,

      I'm not very familier with Test-stand or any Test-stand-specific Excel manipulation tools.  Is it possible that Test-stand is writing to a tab (or comma) delimited text file, and naming it .xls?  If so, then Test-stand is dealing with regular file references and not ActiveX - and I doubt there's a "copy cells" function available.  However...  Excel ActiveX does provide a Range object with a Copy method - here's a quick example of how to use it to copy a range of cells from one file to another.Smiley Happy

Before calling this function both files need to exist and, probably, they shouldn't be opened for writing in Test-stand.Smiley Wink

 

Cheers!

 

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 2 of 6
(3,233 Views)

Wow - I didn't realize my subject was so bad - sorry about that!

 

Unfortunately I don't have any activex experience, although I think what you posted is getting close to what I'd need.  I did try running your vi, and created 2 spreadsheets to use as inputs, but when I run it, the data I have in the first spreadsheet is not being copied into the 2nd spreadsheet.  Any ideas as to why?  I think with your vi copying/pasting, I'd be able to do what I need...

 

Thanks!

-Bill

0 Kudos
Message 3 of 6
(3,190 Views)

There is an example called Write Table to XL.vi in your example finder. This uses ActiveX controls to open Excel and then write data to it. This would be how you would want to "paste" your information. You would also use ActiveX controls to read from your first workbook. You would have to read them in programmatically into an array though and use for loops to write them back in, but it could be done. I don't know of a specific example that is an easy copy/paste though.

0 Kudos
Message 4 of 6
(3,164 Views)

Hi Bill, 

      Here's a VI that will work if the Source and destination are XLS formatted files - note that the target Worksheet names are now required and both default to "Sheet1".Smiley Surprised

 

I did test the previous VI, and it worked - as long as the source and destination files were simple tab-delimited text files (but named .XLS.)  Seems silly in hindsight.Smiley Tongue

 

When this VI is opened, it will search for some VIs that are in the previously-posted .LLB.

 

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 5 of 6
(3,146 Views)

That was exactly what I needed - thank you!!!!!!!!

0 Kudos
Message 6 of 6
(3,126 Views)