Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

"DAQmxErrChk sub or function not defined" vba excel

Solved!
Go to solution

Hi,

 

I'm trying to run an exsisting task that was created in NI Measurement and Automation Explorer inside excel.  I have seen MANY visual basic examples on how to run an existing task, my problem is this:

 

"DAQmxErrChk: sub or function not defined"

 

In the visual basic editor, under "Tools - References" I can choose different libraries to include.  I have included all of the NI libraries I have, and the issue still persists.  I know that the "DAQmxErrChk" function accepts certain arguements, but without it, I cannot find a way to read in a value from the cDAQ card I use (NI cDAQ-9172).  All that I need to do is read the voltage from one input.

 

Any help would be greatly appreciated.

0 Kudos
Message 1 of 5
(4,542 Views)

medendoc,

 

Did you include the DAQmx library nidaqmx.tlb file located in C:\WINDOWS\system32

This KnowledgeBase decribes some of the small difference between error handling in C and error handling in VB.  In your case it sounds like all you will need to do is add the NIDAQmxErrorCheck.bas file from the shared folder.

 

Here is an example of doing digital IO in Excel.

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 2 of 5
(4,529 Views)
When I try to add the "NIDAQmxErrorCheck.bas", the Excel VBA editor says "Can't add reference to specified file".  Could the problem be that Excel's VBA editor does not allow these libraries?
0 Kudos
Message 3 of 5
(4,499 Views)
Solution
Accepted by topic author medendoc
There might be some additional steps to make VBA Excel use a bas file.  In leiu of such an investigation, however, it might be quickest to simply paste the error check subroutine (from the bas file) into your program.  The function is pretty simple (just doing some basic error handling).  Our C examples have a similar function that actually appears at the top of each .c example file (rather than using a separate file).
Thanks,

Andy McRorie
NI R&D
0 Kudos
Message 4 of 5
(4,492 Views)
Thank you AndrewMc, by copying the DAQmxErrChk into my VBA as a private sub, I am able to use the functions.
0 Kudos
Message 5 of 5
(4,462 Views)