Actxcontrol - data transfer to an instrument

Hello,
I need a help regarding a format for a variable to transfer input data to my instrument.
I am trying to communicate via ActiveX with my instrument (Raman microspectroscope). When I enter
LabSpec = actxcontrol('NFACTIVEX.NFActiveXCtrl.1', [15 15 410 390]);
LabSpec.invoke
It says
PutValue(handle, int32, ustring, Variant(Pointer))
Given this, when I enter
PutValue(LabSpec, 0, 'ShutterMode', 1)
It says
Error using COM.NFACTIVEX_NFActiveXCtrl_1/PutValue
Error: Type mismatch, argument 3
I think the last argument was incorrectly inserted. If I need to give "1" (for the argument 3) to the instrument, what type of variable should I use for "Variant(Pointer)"?
Anyone has a good suggestion?
Thanks!
Kang

6 Comments

Hello,
it's unlikely that you will get an answer here for your question. You can try putting your 'ShutterMode' into double quotes, as it expects the string. You should consult with the software documentation on the proper usage of ActiveX controls.
Hi Mario,
Thanks for your comment. I think 'ShutterMode' is okay as this formatting works in my other commands.
Do you have comments on what type of variable (e.g., str, int, ...) should I use for "Variant(Pointer)"? I have tried all types that I can think of, but the same error message was always there. Thank you!
I can't suggest anything, but the documentation, I guess you have to request it from the manufacturer.
You can take a look at methods, maybe you'll find something that'll lead you, but this may end up in huge time loss with no actual results.
methods(LabSpec)
Thanks Mario, I agree.
I think your suggestion:
methods(LabSpec)
is same as what I used
LabSpec.invoke
It told me that I should use the format
PutValue(handle, int32, ustring, Variant(Pointer))
and I am confused what variable and value I should use for "Variant(Pointer)".
In a documentation that the manufacturer provides (Horiba; writtien based on VB), they say to use "array", but this is not very clear to me.
You are right that it would be easier to ask the manufacturer, but it takes very long time to have their inputs (and not very informative). Thus, I wanted to clarify the issue more clearly before contacting them again.
Thanks again!
Kang
Hope you have already resolved your issue.
I encountered an example of documentation that you need, unfortunately not for the same program, just so you can see that you really need to find (maybe it exists in the program manual).
https://docs.microsoft.com/en-us/office/vba/api/excel.workbook.saveas, If you take a look at FileFormat, see the description that'll lead you to another link with so many different inputs that do different thing.
Hi Mario,
Thanks for your geneous helps! I have not yet solved my issue. I see your points and I have decided to contact the manufacturer with what I have been collecting. Indeed, they provide a document for ActiveX-based controls of the system, but it did not very useful to solve this issue. I will make a note here when I hear a solution. Thanks again!
Cheers,
Kang

Sign in to comment.

Answers (1)

As the documentation says actxcontrol To be Removed from Matlab in future releases.
As a workaround to this, If the control does not have UI interaction involved, you can load the control using 'actxserver' in invisible mode and call its properties and methods on your demand. The difference between 'actxcontrol' and 'actxserver' is there will be no figure window. But you are still able to get a handle of control in MATLAB. For more details with 'actxserver',
Refer to the documentation on actxserver for further details.

Asked:

on 11 Feb 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!