Visio clsEventSink 库

Visio clsEventSink library

我想按照 https://msdn.microsoft.com/en-us/library/office/ff767482.aspx 中的指南创建事件对象。当我创建一个变量时出现问题:

mEventSink 作为 clsEventSink

我收到编译错误:未定义用户定义类型

我尝试为此搜索一个库,但我找不到可以提供解决方案的资源。

我猜您要么将所有代码放入一个标准模块,两个单独的模块,要么没有正确重命名 class 模块,但请注意说明中您需要创建一个class模块(即不是标准模块):

Copy this sample code into a new class module in VBA or Visual Basic, naming the module clsEventSink. You can then use the event-sink module that follows to create an instance of the clsEventSink class and an Event object for the MouseMove event that sends notifications of event firings to the class instance.

因此,实现 IVisEventProc 接口的第一部分代码进入 class 模块,第二部分使用 Initialize 方法进入标准模块。