I'm trying to use VBScript to access functions within a VBA file (or a DLL). I'm quite a bit out of my depth, and I don't normally use either of these languages, so I'll explain the situation, in case there's a better solution.
I have an instrument that has an internal VBScript-like window (it has some features not found in VBScript, such as an "Include...End Include" statement) that can be used to automate instrument operation, and I'm trying to use this in combination with a camera. For the camera, the company supplied VB (atmcd32d.bas) and C++ (atmcd32d.cpp) files containing all the necessary functions (e.g., GetTemperature, StartAcquisition, etc.) for communicating with a DLL file (atmcd32d.dll), which I assume sends commands to the camera. If I were using C++ or VBA, I assume I could directly include those files, which would give my code access to the commands needed to control the camera. However, the scripting language used by the software of the main instrument is closest to VBScript. The script lets me include the file if I change it to .txt, but of course it fails when it gets to commands like "Attribute", "ENUM", and "Declare Function", which aren't part of VBScript.
I was wondering, first, if there's a better way to run the .bas file.
Alternatively, I thought I could try to translate the functions that I need from the .bas file, so I could communicate with the DLL from VBScript. This changes one problem into 2 problems. The first problem it creates is the translation, and I'm not sure if that's a realistic approach. Since it's a 750 line file, I wanted to ask others first.
The second problem is how to communicate with the DLL. I found a page on using VBScript to communicate with a DLL: How to call C# DLL function from VBScript
And I tried to use that approach. For my case, I assumed that the DLL is already registered, since it was installed along with the camera software, so I just need to use:
Set obj = CreateObject("C:\MyPath\atmcd32d.dll")
to get access to the camera functions. But if I run a script with only that line, I get the message "ActiveX component can't create object". Does this mean the DLL isn't registered? Or did I make some other error?
I apologize for the convoluted question, but given how far I've gotten in over my head already, I figured I should ask for help before I dug too deeply in the wrong direction.