LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open new document in Word using .NET

I would like to learn to use the .NET environment within LabView. As a warm up to using LV to control some Filmetrics software via .NET (recommended by them), I am trying to learn to use .NET with some common software that might be familiar to others. In the attached simple vi, Word will open but it will not create a new, blank document. There is probably some simple step I do not understand. Can anyone help me to get started or point me to a relevant tutorial? I have looked at the Calculator example but it does not offer the wide range of constructor choices that Word does and I would like to know how to filter through these choices to find the correct structure.

Thanks, Peg

0 Kudos
Message 1 of 11
(4,596 Views)

When you hover over a Constructor, you can see the name of the Interop Assembly to which the Constructor belongs:

 

19575iED87AED09B1EAF70

 

Now, Googling "site:msdn.microsoft.com Microsoft.Office.Interop.Word" brings up this page, which is an exhaustive reference of all elements inside the Assembly. From here, the best method is to visually scan until you see the method/property that sounds like it will do what you want it to! If a quick scan turns up dry, try choosing some simple words to describe the task you want to accomplish and search for them on StackOverflow.

 

This method has been generally successful for me while using .NET in LabVIEW.

0 Kudos
Message 2 of 11
(4,586 Views)

Many thanks for that reference information. If you know how, could you show me what you would do to start a new document in Word (or anything else that would get me past merely opening Word)?Though I can scan through the choices on the suggested web page, I still think I have chosen something that makes sense to me (see attached vi). What am I missing? I am assuming I have to choose from the application events that appear when I choose "Select Method" on the Invoke Node. I think I am missing something simple.

Thanks, Peg

0 Kudos
Message 3 of 11
(4,581 Views)

Attached is another attempt at getting a new document. If anyone can point out where I am going wrong, I would be grateful.

Peg

0 Kudos
Message 4 of 11
(4,575 Views)

Trying to open/control Word through the .NET Interop assemblies is a poor choice to try out in order to learn to use .NET in LabVEW. Have you looked at the examples that ship with LabVIEW regarding .NET as well as the numerous KnowledgeBase articles?

0 Kudos
Message 5 of 11
(4,566 Views)

Could you point me to a very basic tutorial that would be a good starting place? I have looked at Calculator.vi, but it isn't clear to me if that calls a stand-alone application the way I will eventually need to be calling. I have searched the tutorials (filtered for LabView) and nothing seems relevant, but I probably don't know enough to get started. Eventually, we want to open and control Filmetrics within LV in order to coordinate its data taking with a LV control of a stepper motor. So I just wanted to try opening and controlling something within LV that is available on my home computer for practice. Have you a recomendation?

0 Kudos
Message 6 of 11
(4,558 Views)

hi peg,

  Have you tried your control of filmetrics aplication using C# or VB.net over visual studio or have you gone thorugh the help manual/function reference.If you able to control in visual studio,you can program as it is in labview also..Generally that is my approach if i want to use any .net reference in labview.

 

 

Thanks and regards,

srikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 7 of 11
(4,549 Views)

There is a big difference between calling a .NET library from LabVIEW and trying to control a stand-alone application (regardless of what language was used to write it) from LabVIEW. The former is relatively easy. You place a constructor node to create the class(es) you're interested in, and then call the appropriate methods and properties. A stand-alone application, on the other hand, does not usually lend itself to this kind of control. It's mean to be used stand-alone, and unless it has some sort of external interface, you will need to find some other means to control it. If you search the forum for "remote control executable" you will see this issue has come up many times.

 

So, the question becomes: are you trying to call a .NET library, or are you trying to control a stand-alone application. And, if it's the latter, what sort of programming interface does this application have?

0 Kudos
Message 8 of 11
(4,541 Views)

Is there only one answer to this question? Filmetrics provides software that runs "stand-alone" and they also provide "public assemblies" for use with .NET. Are "public assemblies" the same as what you call a  .NET library. So the software is made to run alone. But we are also controlling a stepper motor via DAQ output using LabView and want to coordinate the position information with the data returned by the Filmetrics software. Filmetrics says to use .NET (I have never used this). They have no sample LV vis to share but they do provide some Visual Basic source code.

 

What we want is for LV to control the steps, tell Filmetrics to take a data point and save the position and thickness data together in one file. Having written LV vis to control DAQs and save data for several years, that part is not a problem. I have never tried to control another program through LV and wanted to practice that, mainly in order to understand the unfamiliar terminology (constructor, objects, methods, etc) so that I can make sense of all the choices. So all that about running Word is really off the mark. I just thought it would be software that anyone would have and therefore be able to provide assisitance in learning how to embed an application in LV.

0 Kudos
Message 9 of 11
(4,531 Views)

Yes, public assemblies are what I refer to as a .NET library. A public assembly implies something that is installed into the GAC (Global Assembly Cache) as opposed to a private assembly, which is something that is typically copied with the application that uses it (and will usually reside in the same folder as the application itself).

 

If they've provided VB.NET code then you can follow that code to basically do the same thing. The constructor is used to create an instance of the class you need to use. Once you have the instance of the class you can access its properties and call its functions (methods) to do what you need. There are several examples of calling .NET assemblies from LabVIEW. Here's a few:

 

Calling .NET Assemblies From LabVIEW

Calling .NET Assemblies from LabVIEW (different article, same title)

Instantiating .NET Objects from LabVIEW

 

Do you have any documentation for this Filmetrics software? Perhaps a link to it?

 

0 Kudos
Message 10 of 11
(4,520 Views)