LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview code to copy and paste data in Excel

Can anyone please send a labview code that for e.g. copies data from A1:B2 in an Excel sheet and paste it to C4. If I have this I can do what I need. I tried modifying some codes such as Set Cell Valu.vi but I did not sucseed (being unfamiliar with Prperty and nodes ...). Thanks a lot
0 Kudos
Message 1 of 9
(3,972 Views)
What I do when I have to do something with excel or word is to create a macro then duplicate the macro in labview or call the macro in labview. here is an example that takes a macro and duplicates it using property nodes. Look at this example and I'm sure you will have specific questions.



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 2 of 9
(3,952 Views)
 



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 3 of 9
(3,947 Views)
Here is the exact code you requested. Note that there is no paste function used. The Copy command specifies the destination and the copy is performed immediately. You need a reference to the sheet to use this VI. This VI uses LV6.0.3 and Excel 2003.
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 4 of 9
(3,939 Views)
In the applications I've build, the simplest way I found to get and write arrays in Excel was to use a text file as intermediate. For saving an array under Excel, I write it in a text file, then open the text file under Excel and save it as an Excel file. It avoids having to write the cells one-by-one.
I hope it will help you...
0 Kudos
Message 5 of 9
(3,929 Views)
I run the program under Labview 7.1 and Excel 2002 and got the error message 97:
"Unknown System Error in Excel_copyA1B2toC4[1].vi".

The reference sheet got opened but nothing after this happened to the excel sheet. Thanks
0 Kudos
Message 6 of 9
(3,912 Views)
Thanks for your help.
I tried to do it in the past the way that you said: starting with the Excel macro and then making it in Labview. I think the reasons that there are instructions that appear in the macro that I could not find in the Labview (search in the help was not really helping). Also for some instructions you need first an instruction that does not appear in the macro.

For e.g. in your code:

you have "activecell" in the macro which does not appear in the Labview. Also it is not clear to me when I am supposed to use a Property node versus an invoke node. Anther point that I have not yet figured out is why the "Item" is wired to "Variant to Data"? These are obviously basic questions but I could not solved them using the help in Labview or some references that I found on the Internet.

Would you please suggest a good reference to start with for a beginer (I am familiar with Labview for many years but beginer in the area that is required to write an Excel application or similar).

Best regards
0 Kudos
Message 7 of 9
(3,901 Views)

alisol,

There might be a difference in the active x calls between your Excel 2002 version and the 2003 version that the vi you used was written for. I think you would get a different error for that though. As for your specific error, here is a knowledgebase from our website that discusses the error and has a couple of useful links:

Error 97 When Using the Excel Macro Example VI [link no longer available]

I hope this helps you out!

Tyler S.

0 Kudos
Message 8 of 9
(3,874 Views)
Here, try this VI for LV7.1. It should eliminate the error.

I added a separate Worksheet.Range function for the Destination and tested it with the Write Table to XL example. Worked perfectly.
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 9 of 9
(3,862 Views)