LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a picture to excel file using ActiveX

Solved!
Go to solution

Hi,

 

I want to add a figure that has been produced using data from DAQ to some specific cell in my existing excel file (inverting a graphic indicator to jpg/bmp,... and put it in the excel file). But I cannot find the specific method to do so. I already have changed one of the examples so I can add some numbers to a specific cell in excel file (attached VI). Anybody knows how to do that?

 

Also, in my test, I am going to do this for 15-20 numbers (put 20 numbers in different places in existing Excel file). Should I do this one by one? (opening the application 20 times) or there is a way to just do all at the same time.

 

Thanks. 

 

0 Kudos
Message 1 of 21
(9,592 Views)

Baran,

 

Here is what you have to add:

 

excel_Picture.jpg

 

Paul

 

PS: I was to lazy to close the references. But you must do it Smiley Very Happy.

Message 2 of 21
(9,583 Views)

Hi!

 

Maybe this thread can help? Check out the posts, the pictures and the VI's there. I often add pictures to my Excel Reports. Mostly graphs. Using invoke node export image to clipboard, I can easily paste the image in my report using one of the VI's in the Excel Tool Kit. Maybe you're using MS Office Report Generation Toolkit in LabVIEW? If not, you should check out the Free tool kit. It's using ActiveX.

 

If you choose to use The Free Toolkit, I can add an example on how to paste images into Excel-files.

 

Btw! The Free Excel Toolkit, is basically what you have in your VI, but since it's already made for you in the toolkit you'll just work with sub-VI's and you don't have to create all the ActiveX code.

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
Message 3 of 21
(9,578 Views)

Don't forget to close references in the correct order too. Many an Excel ActiveX user has come unstuck this way. Workbooks looks awfully like Workbook etc etc

Don't forget to give Kudo's for a good answer !

LabVIEW Champion
Certified LabVIEW Architect
Certified TestStand Architect
0 Kudos
Message 4 of 21
(9,565 Views)

Thanks everybody.

 

IT was really helpful. 

Just some questions: When I have two parallel flow of data, like Paul's example; in what order should I close the references? Separately and in the reverse direction?

 

Even, 

You mentioned "Free Excel Toolkit". I don't know which toolkit is that? Is  that the ActiveX toolkit?

 

Also, anybody knows if I should do the exact same thing several times (open the application, put a number, close it, and then the same for next number)? or there is another way. 

 

Thanks again.

0 Kudos
Message 5 of 21
(9,543 Views)

Paul,

 

I did as you said, and it gives me error or the labview just freezes. Attached is what I did.

 

0 Kudos
Message 6 of 21
(9,540 Views)

Baran,

 

What I wanted to point out was the Property node and the Invoke node that you have to use. What I did there shouldn't be normally done. 

Save your VI for LabView 8.5 (on my personal laptop I have a basic version of 8.5) and I'll do it right.

 

The error could come from the fact that you close the same reference twice. The worksheet reference (_Worksheet/Range and _Worksheet/Shapes) is closed twice. And one of it generates an error. 

 

Paul

Message 7 of 21
(9,533 Views)

Oh. It worked. I guess I should have wired the error messaging right.

 

Still, I am wondering if it is possible:

- To put all data and pictures once, without openning/closing the application each time

- Put the picture directly from a waveform graph

 

thanks.

0 Kudos
Message 8 of 21
(9,526 Views)
Solution
Accepted by topic author Baran

Now it looks much better.

 

I also added the part in which the image is taken from a Waveform graph. For this you have to use the Waveform graph Invoke Node Export Image. I exported it as bmp, save it in a file and then added it in Excel. This is a solution. You can try different image format in order to find one which is more suitable for you. BMP is pretty big.

Another solution would be to use Waveform Graph / Invoke Node / Export Image to Clipbord and to Use from Worksheet Invoke Node / Paste function. This way you don't have to write the image to file. Though I find it harder to control the position where the image is pasted. Anyhow you can give it a try and play a bit with it. 

 

You can build your entire Export To Excel code using this example. You just have to add a loop (or your code) between the Opening the Workbook and Closing it. 

 

PS: I hope the Waveform Graph invoke node is the same also in LV2010. I can check this only Monday. 

Message 9 of 21
(9,524 Views)

Thank you very much Paul. 

 

I was using the invoke node/Export image to save my graphs in the folder, but I thought maybe the sequence of the commands would not let me do this (I mean it should save the file first and then put it in the excel; otherwise it doesn't work that way).

 

Thanks again for your time,

Baran. 

0 Kudos
Message 10 of 21
(9,520 Views)