02-18-2021 05:19 AM
Hello everyone,
I want to control the LabVIEW application from MS Access. But before that I would like to make it work in MS Excel. Once it works with MS Excel it should work with MS Access too.
The task is: I press a button in MS Excel and it should go to the LabVIEW application and read the data and send it back to Excel. In the next step I also want to send data to LabVIEW via a similar or same button from Excel.
I am trying to do it with ActiveX. I created a simple LabVIEW application of Blink_led and I am trying to get the value of 'millisecond to wait' control from LabVIEW. I have attached the LV file.
I also created a ActiveX button in Excel and wrote a small VBA code. The snippet of the VBA code and the Excel is attached.
My problem is that when I click the button in Excel,I get an error '80040154' saying Class not recognised. The error points to line 'Set lvapp = CreateObject("Blinky.Application")'. I have added the .tlb library file of the applicaiton in Tools>References in VBA editor. I have searched through google for the error but could not find a suitable working solution.
Can anyone please help in resolving the issue? Or can you suggest any way by which I can complete my task?
P.S. - I am new to ActiveX.
I am working with LV 2014 and MS Office Professional Plus 2010.
Thank you in advance.
Solved! Go to Solution.
02-18-2021 07:33 AM
If you have the Report Generation Toolkit, it should be relatively straight-forward to let LabVIEW "drive" Excel, but to have Excel be the "driver" is, I believe, considerably more difficult.
Bob Schor
02-18-2021 07:48 AM
Hello Bob,
Thank you for your reply. I have the Report Generation Toolkit. I have even tried it out and it works perfectly fine.
But as I mentioned earlier,at a later stage I want to control LabVIEW from MS Access. I know that data can be communicated with the Report Generation Toolkit with MS Access as well. But there is an issue in that too. The database format which I have in MS Access is (.adp) format, which is no longer supported. Also, with the Report Generation Toolkit I could not exchange the data because of this format.
So, I am trying with ActiveX communication so that it does not depend on the format of the database files.
02-18-2021 10:46 AM
If you do a Web Search for LabVIEW Sql, you will find NI Software that says it can connect to Sql and to Access. If you, instead, search for LabVIEW Sqlite, you should find James Powell's excellent Video about LAVA's SQLite Library for LabVIEW.
Again, both these methods involve LabVIEW being the "controller", that is, reading and writing databases that are compatible with Access, SQL, or SQLite, not directly interacting with those programs.
Bob Schor
02-18-2021 11:48 AM
We need to understand why you want Excel/Access be the driver and not LabVIEW. From your earlier posts, it's not clear...at least to me.
02-19-2021 01:44 AM
Hello Eric1977,
Basically, I want to automate a test sequence which runs in LabVIEW. At present, test results data is stored manually in MS Access database. So, I do not want to make changes in the exisiting LabVIEW application which is used for testing. I want to acquire the data directly from MS Access application with help of a button or any control.
So, when I press the button in MS Access, it should go to the LabVIEW application, run the code there and send the values back to MS Access and get filled in the respective column of the MS Access table.
Sorry if it is too confusing. I am trying my best to explain the situation.
02-19-2021 01:48 AM
Hello Bob,
I want to avoid tampering with the SQL directly. As, if by any chance it goes wrong anytime, it might affect the whole SQL database.
As I explained earlier, it will be best if I can acquire the data from MS Access without touching the LabVIEW application physically.
02-19-2021 07:07 AM
That seems very backwards. Why not just enhance the program to do everything in the LabVIEW app and, when done, save the data to the MS Access application?
The only way I could even think of doing this is through either a UDP or TCPIP connection which I don't know of any VBA code that handles that. Anyway, you'd need to get into the LV app and modify that & at that point, I'd just do everything inside the LV app.
Seems like more trouble than it's worth.
02-26-2021 01:43 AM
Hello everyone,
Thank you for your time and responses.
I wanted to control LabVIEW from MS Access, because the LV application was already developed and is already in use. So I did not want to tamper anyting in the LV application. Secondly as I mentioned earlier, the format of my MS Access database file is (.adp), which is no longer supported and is not accesseble from LV.
Anyways, I managed to do my task and it works really awesome. I am mentioning the steps which I followed:
Steps to control LabVIEW (as server) from MS Access (as client) via ActiveX
Dim lvapp As Blinky.Application
Dim vi As Blinky.VirtualInstrument
Dim viPath
Set lvapp = CreateObject("Blinky.Application")
viPath=".................\builds\Blinky\Blinky.exe\Blink_led.vi "
Set vi = lvapp.GetVIReference(viPath) 'Load the vi into memory
Call vi.SetControlValue("stop", False)
Call vi.SetControlValue("Boolean", True)
Call vi.SetControlValue("milliseconds to wait", 500)
'Wait for 10s
T0 = Timer
Do
Delay = Timer - T0
E = vi.GetControlValue("Boolean 2")
f = vi.GetControlValue("milliseconds to wait")
Text3 = E
Text1 = f
Loop Until Delay = 10 'Change this value to pause time in second
'Stop the VI
Call vi.SetControlValue("Boolean", False)
Call vi.SetControlValue("stop", True)
E = vi.GetControlValue("Boolean 2")
f = vi.GetControlValue("milliseconds to wait")
Text3 = E
Text1 = f
'Wait for 1s
T0 = Timer
Do
Delay = Timer - T0
Loop Until Delay = 1 'Change this value to pause time in second
'Close the application
lvapp.Quit
I hope someone finds this useful in their future projects.
Thank you all once again.