DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Use of DIAdem functions in Excel VBA? Like digital filtering.

I was wondering, can I use DIAdem functionality in my Excel VBA code?  I see in the Excel VBA editor, I can set a reference to DIAdem.  In DIAdem, there is a CommandExecute method.  With this method, can I execute a DIAdem function on some Excel data, and get it to return values to Excel?  Specifically, I would like to execute DIAdem's digital filtering commands on some Excel data.
 
Thanks for any help.
0 Kudos
Message 1 of 7
(4,922 Views)

Hi Internati...

VBA can call external DLLs and ActiveX servers, and DIAdem has two ActiveX servers available (ToCommand, ToDataSheet).  So yes, any application (even Excel) can call DIAdem through ActiveX, send it data over ActiveX or send a file path and tell it to load the file, then tell it to run some analysis and send the results back to the calling application.  This requires that DIAdem be installed on the same computer that the calling application (i.e. Excel) is on, but it should work fine, if you're willing to put in the programming effort.

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 2 of 7
(4,909 Views)
Thanks for the reply!  So, if the data is in the Excel spreadsheet, I can write some code to send the data in, say, column A, to DIAdem to filter it, then have DIAdem send the data back to Excel in column B?
 
Or can Excel only tell DIAdem to load data stored in a file?
 
Is some example code packed with DIAdem (I have version 11), or available on the web?
 
Thanks again for the help.
0 Kudos
Message 3 of 7
(4,906 Views)
Hey InternationAL,

As far as examples go, if I were you I'd take a look at the "Controlling DIAdem with OLE" example that can be found under Help » Examples » Creating Scripts » Using Interfaces.  This example gives you a good start with how to use the DIAdem TOCommand ActiveX server and uses the help document to programmatically control DIAdem to launch a new REPORT layout.
Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 4 of 7
(4,899 Views)

Thanks for the additional reply!  It appears that I would have to use OLE to "write" the data to DIAdem, then execute the DIAdem command I want on the DIAdem data, the use OLE to "write" the results back to Excel.  I hope I have the steps correct.  It also appears the only way to do this is value by value.

I shall give this a try.

Thanks again!

0 Kudos
Message 5 of 7
(4,878 Views)

Hi Internati...

You have the steps correctly outlined.  There are methods in the DIAdem ActiveX server to send and receive blocks of data, but I honestly don't know if they will be compatible with the blocks of data that you can read and write with VBA in Excel.  These methods were created with C pointers in mind, and they do not work with native variant arrays.  Still, VBA can explicitly data type variable, so perhaps it could work, but I can't help you with the details.  The simplest approach would be the following:

1) Assemble a variant array from all the Excel cells
2) Send the variant array to DIAdem via ActiveX
3) Assign the variant array to DIAdem channels using "ArrayToChannels()"
4) Run the DIAdem analysis to create result channels
5) Assemble a variant array from all the DIAdem cells in the result channels (cell by cell)
6) Send the variant array back to Excel via ActiveX
7) Assign the variant array to target Excel cells

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 6 of 7
(4,869 Views)

Thanks, Brad and DRock!  This looks doable.  I appreciate your efforts and time on this one.

Time to code!

0 Kudos
Message 7 of 7
(4,865 Views)