Quantcast
Viewing all articles
Browse latest Browse all 1794

Help with VBA Code - by: cdunlap

Hi,

I am having some trouble building off of one of the VBA Excel examples and I was hoping to get some input on it. This is not specifically related to a problem with the component itself, but more on why certain code works and certain code does not work. I am sure it's more of a lack of knowledge of VBA than anything else, but i was hoping that you could help Image may be NSFW.
Clik here to view.
:)
.

Basically, If I run the code in the UASubscribeToMultiple3.xls file, everything works great.

I have a customer that tried modifying the declaration of the MonitoredItemArguments to use the 'New' keyword as opposed to a call to CreateObject(). It will not allow anything to be assigned to the 'State' variable, and gives an error message, but I cannot figure out why.

So the original code looks like this:



The slightly altered code looks like this:



The altered code gives back an error on the line that tries to assign a value to the 'State' object that says "Run-time error '424': Object required".

From everything that I can find, it sounds like CreateObject and New are somewhat interchangeable, but that doesn't seem to be the case here.

So basically, I am stumped as to why CreateObject works, but defining it with the 'New' keyword does not. I know that this is more of a VBA question than a specific question about this component, but I was hoping I could get some insight.

Thank you in advance for the help

Viewing all articles
Browse latest Browse all 1794

Trending Articles