View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Erich Neuwirth Erich Neuwirth is offline
external usenet poster
 
Posts: 41
Default Class module creating OLEObject

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?