Testing Active X DLL - runtime error 91 object variable or With block variable not set

强颜欢笑 提交于 2019-12-24 20:03:17

问题


I created a skeleton Active X DLL with its Instancing property set to MultiUse and only one function which does nothing but pop up a message box saying that it has been called.

Then I created a test program and added the DLL to its References.

I added code to declare a variable of the DLL's Classmodule, to create a new object and to call the function.

In all cases I used Intellisense code completion, so VB6 certainly about the DLL and it's class & method.

However, when I run the tester it reports runtime "error 91 object variable or With block variable not set" when trying to create the New object.

This is new territory for me, so hopefully it is something obvious.


Update: I added a message box in a DLL fn() to say that it had been called, then went to a real life web site that uses Active X to call into the DLL and saw the message box - but I still get the error in a VB tester application(!?)


回答1:


It would be easier to find the problem if you could post the calling code and the DLL class.

Here's a guess. Have you remembered the Set on the line that creates the new object?

Correct code

Set obj = New MyDLL.MyObject

Incorrect code

obj = New MyDLL.MyObject



回答2:


Try changing the function in your active x dll to return a message instead. Show your message box in your calling code, not in the dll.

Else, try in command prompt, regsvr32 "myDll.dll", and then run your code.



来源:https://stackoverflow.com/questions/3626540/testing-active-x-dll-runtime-error-91-object-variable-or-with-block-variable-n

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!