Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Using CallMethod in VBA

More
07 May 2020 15:37 #8473 by gkalipershad
Hello,

I just saw in another forum post that you mentioned that Quick Reply is broken, which makes sense considering I posted two responses using that and never saw them afterwards.

Anyway, using the Array() function to pass empty arrays in place of the unnecessary arguments worked for the customer, they are quite happy, and already purchased the toolkit. Thanks!

GK

Please Log in or Create an account to join the conversation.

More
06 May 2020 17:21 #8471 by support
Replied by support on topic Using CallMethod in VBA
Hello.

There are no optional arguments in COM API of QuickOPC (which is what VBA gets to use). All arguments need to be specified. And, there aren't multiple overloads - for a given method name on an object, such as CallMethod, there is just one set of arguments (this is a general COM limitation).

So, you really need to specify all arguments to CallMethod. This means passing in an empty array if the UA method has no arguments. I cannot test it out right now, but on the Internet I have found that the Array() function might do it (can be given list of elements, but the list can be empty).

Can you please try out something like:
outputs = Client.CallMethod(..., ..., ..., Array(), Array())

The last part of your post is not clear to me. Are you saying that the methods that have arguments do work OK for the customer? In such case he needs to pass in the inputs values and typeCodes similarly to what you have written - so assuming that it works when the methods do have input arguments, I could imagine that passing this to a methods that does not have arguments could lead to an error, but I would expect that be an OPC service error, rather than what you have shown - because he is basically passing in the same as that he is passing elsewhere. Can you somehow elaborate/explain, or provide full examples?

Thank you

Please Log in or Create an account to join the conversation.

More
06 May 2020 13:26 #8470 by gkalipershad
Hello,

I am working with a customer who is using methods in OPC UA. Initially, we had tried to steer him towards the Excel Add-In, but he preferred to work with VBA due to comfort. This issue is the only thing holding up a license purchase. They are testing with 2020.2.

One of the UA Methods that the customer is using does not have any InputArguments, and therefore, I would expect them to use the overload that omits the input and type, since they are optional arguments. However, in VBA, when these are omitted, we see an "Argument not optional" error.

docs.microsoft.com/en-us/office/vba/Language/Reference/User-...rgument-not-optional-error-449

So my question is, how do we declare arguments of the CallMethod function as optional when the function is not user-defined? Alternatively, is there a way to pass null entries instead?

The customer does have other UA Methods that include inputs, so he does have arrays configured for the inputs and typeCodes. One thing that I suggested he try is include "inputs(0) = False" and "typeCodes(0) = 0 'TypeCode.Empty" as part of his arrays and pass those as the arguments, but that results in the attached error.

Any help would be much appreciated.
Attachments:

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.062 seconds