Class module creating OLEObject

E

Erich Neuwirth

I recorded the following macro, and it works.
-=-
Sub Macro1()
Dim ooo As Object
Set ooo = ActiveSheet.OLEObjects.Add(Filename:= _
"C:\Documents and Settings\neuwirth\My Documents\Watermark.pdf", _
Link:=False , DisplayAsIcon:=False)
End Sub
-=-

Now I created a new class module named myobj
which contains

-=-
Dim WithEvents oleobj As OLEObject

Sub Class_Initialize()
Set oleobj = ActiveSheet.OLEObjects.Add(Filename:= _
"C:\Documents and Settings\neuwirth\My Documents\Watermark.pdf", _
Link:=False , DisplayAsIcon:=False)
End Sub
-=-

Then I defined a macro

-=-
Sub testit()
Dim mypdf As myobj
Set mypdf = New myobj
End Sub
-=-


testit does not run, I get an error
Run time error 459
Object or class does not support the set of events.

I do not understand this.
Can anybody help me?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top