LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running VBA procedure from LabVIEW

******************************
Elvis Poprzenovic
LACO Technologies
www.lacotech.com
elvisp@lacotech.com
801 486-1004
Fax 801 486-1007
******************************

Attention: Jeremy Licup

Hello Jeremy,
I e-mailed you two weeks ago, and probably you have not received my e-mail
for some reason.

Anyway, thank you very much for your response. Let me tell you first what
exactly we are trying to do. We have automated one of our systems for leak
standards calibration, and it works very well. However, we need to store
our
results in our database (Access), and reading from tables, writing to
tables
and running queries work fine. However, we want to print our calibration
certificates and stickers from Access, and to do that we need to run a VBA
procedure from Labview.
I have tried that Call_Stored_Procedure vi. as it is - I have just changed
the name of the database and in SQL query field I�ve put the name of our
procedure and it did not work. My error message says that I should use
PROCEDURE, SELECT or UPDATE, and I have tried them (for example I typed
SELECT �procedure name�, and similar), and nothing worked. In that example
they use statement {call sp_helpuser (?)},I�ve tried it and it does not
work, and I don�t know if I should use a similar statement, but I don�t
know
much about SQL statements, and that may be my problem.
I have also tried to use just Execute query vi, with Free Object vi, after
it and it executes a regular query fine, but if a query has a function than
it does not work, also it does not work with VBA procedures.
As for Active X, I don�t know exactly how to use that palette, and I would
appreciate a lot if you could send me a step-by-step instructions on how to
use them (assume that I don�t know anything). I have been blindly
experimenting with them, and probably I was doing it wrong. I would also
like to know how to use Run Macro vi in Active X.
Also I tried System Exec vi, but the problem is that all those VBA
procedures in Access have just a general, but not a specific path, so this
approach didn�t work neither.
I think that the best way to help me would be to create some dummy Access
Database and a dummy VBA procedure in Modules section of your database, and
then try to execute it from a LabView program. After you have it working,
please e-mail me your program. I believe it should be a rather simple
program, and I just don't know a trick to make it work.

Jeremy, thank you very much for your help!!!

Best Regards
0 Kudos
Message 1 of 7
(6,809 Views)
Hi Elvis,

I took a look at that example and also found that it was built for SQL server, not necessarily Access. The difference is in the way it stores procedures. I have attached an example program that calls a stored procedure (or query) in Access on a sample database and gets called in LabVIEW. Please try this and let me know what you think! thanks

Jeremy L.
National Instruments
Jeremy L.
National Instruments
0 Kudos
Message 2 of 7
(6,810 Views)
Hi Jeremy,

Thank you Jeremy for your response. Your example works fine, I have tried it before, but again, that is not what I need. I need to execute exclusively a VBA (Visual Basic for Applications) procedure, and that procedure MUST BE in MODULES section of Microsoft Access Database) in order to work. In your example your procedure is in the QUERY section of the database and it is not a VBA procedure.
It would be awesome if you could send me a similar example, but this time with a "dummy" VBA PROCEDURE (Visual Basic for Applications) stored in MODULES section of your "dummy" database.

Thanks again for your efforts to help me!!!!

Best Regards
Elvis Poprzenovic
0 Kudos
Message 3 of 7
(6,809 Views)
Hi Elvis,

After several different tests, I was unable to access a VBA procedure (module) from outside of Access. This appears to be a limitation of Access, in that user-defined VBA procedures cannot be called outside of Access. The reason for this is that the Jet Engine that is used to communicate with Access doesn't know about these user defined functions, and will therefore say the function is undefined when trying to call it from LabVIEW. You can only use the VBA functions designated in the "sandbox" when running Jet queries outside of Access. Here is a msdn link to a document related to this issue. Your best workaround will have to be getting the data into t
he database and then working in VB from inside Access instead.

Jeremy L.
National Instruments
Jeremy L.
National Instruments
0 Kudos
Message 4 of 7
(6,811 Views)
Hi Jeremy L.
Since this was originally posted 2 years ago it may have already been addressed.
Access procedures can be called from Labview.
The trick is to open the module containing the procedure before trying to run the procedure.
I have included a quickie example.
 
Message 5 of 7
(6,583 Views)

JermeyL or anyone I have tried most of the day to get the VI that JermeyL posted to work.  Even though the procedure is present in "Module1" and it is made public, I keep getting the message "Procedure Not Found".  Can anybody please help?

0 Kudos
Message 6 of 7
(5,127 Views)

Never mind I got it to work now.  Not sure what I did but it does work now.  I do recall I left for a while and came back which cause me to Restart Labview.

0 Kudos
Message 7 of 7
(5,105 Views)