LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel and .NET Problems

Solved!
Go to solution

I know there is the RGT toolkit which I have and ActiveX which works, however, I would like to know if anyone has a solution to this problem using .NET. (@PhilipBrooks, .NET guru, if you are reading this.)

 

I am having problems determining the number of workbooks open with Excel and whether a particular file is open. Note the ActiveX versions posted here DO WORK, however I want to know why the .NET solutions do not work.

 

PNGs and VIs are attached.

 

Thanks for your help.

 

Regards,

mcduff

 

ActiveXCount.png

 

getReftoOpenEcel.png

 

 

 

 

Download All
0 Kudos
Message 1 of 16
(4,461 Views)

Can you post the VIs for 2016 or earlier?

0 Kudos
Message 2 of 16
(4,443 Views)

Thanks for looking into this.

 

mcduff

Download All
0 Kudos
Message 3 of 16
(4,439 Views)

I've had no success yet, but based on this article I think you want the _Application property. The ApplicationClass is reserved for internal use. But when I select _Application it says no public constructors are available...

Message 4 of 16
(4,428 Views)

@Gregory wrote:

I've had no success yet, but based on this article I think you want the _Application property. The ApplicationClass is reserved for internal use. But when I select _Application it says no public constructors are available...


No, I think the ApplicationClass is correct.  However mcduff's code is creating a new instance of Excel, not grabbing the already opened instance.  If you put an ApplicationClass.Visible = True, you can see it flash onto the screen and then close. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 5 of 16
(4,412 Views)

This still does not work, but you can convert to a more specific type to the _Application Class, even when I use this class I can not get the count or find item. I think aputman is on the right track, we need a reference to the excel application that is running.

 

mcduff

snip.png

 

 

 

0 Kudos
Message 6 of 16
(4,397 Views)
Solution
Accepted by topic author mcduff

There is a way to do this in C# but I haven't figured out how to port this over to Labview .NET.

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 7 of 16
(4,378 Views)

I think you are on the right track. Based on your previous comment, I too have been looking for the "GetObject" call in .net to try and get the current instance of excel. However, I cannot find it in any of the libraries that supposedly have it. I think if we can find that, then it may/should work.

Thanks again for looking.

 

Cheers,

mcduff

0 Kudos
Message 8 of 16
(4,373 Views)
Solution
Accepted by topic author mcduff

Thanks for your hints I think a found a solution to get the current instance of excel. Thanks for your help.

 

See snippet and VI.

 

mcduff

snip2.png

 

 

 

Message 9 of 16
(4,363 Views)

Awesome.  I will have to take a look at this on Monday because I couldn't figure out how to get the Marshal object.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 10 of 16
(4,355 Views)