Hi,
Apologies, I screwed up with a typo. AcEvents was another class identical to AccessEvents. The problem is the same.
class AcEvents def OnActivate(self): print "Hello from Access" return 1
<snip> self. ac = Dispatch ("Access.Application") self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") self. fm = self. ac. CreateForm () self. ac. Visible = true self. fm = DispatchWithEvents (self. fm, AcEvents)
blows out with
self. fm = DispatchWithEvents (self. fm, AcEvents)
File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 258, in DispatchWithEvents
clsid = disp_class.CLSID
AttributeError: 'NoneType' object has no attribute 'CLSID'.
Second code snippet has the same screwup:
self. ac = Dispatch ("Access.Application") self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") self. fm = self. ac. CreateForm () self. ac. Visible = true self. ev = AcEvents () self. fm. OnActivate = self. ev. OnActivate
this couldn't set the OnActivate attribute with the following error.
File "D:\pyhack\1\Bob.py", line 132, in DoAccess
self. fm. OnActivate = self. ev. OnActivate
File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 503, in __setattr__
d.__setattr__(attr, value)
File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 463, in __setattr__
self._oleobj_.Invoke(*(args + (value,) + defArgs))
TypeError: Objects of type 'instance method' can not be converted to a COM VARIANT
Tim Golden wrote:
[Robert Kaplan]
| I'm new to the mailing, so greetings all!
Welcome. As a word of warning, this is a relatively low-activity list and I don't know what the overlap is between this and the main python list. If you get no response (or no solution) here, you might want to try the Python list.
| I'm working on an application try to respond to events in Microsoft | Access using Python and win32com.
| class AccessEvents
| def OnActivate(self):
| print "Hello from Access"
| return 1
| | <snip>
| self. ac = Dispatch ("Access.Application")
| self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo")
| self. fm = self. ac. CreateForm ()
| self. ac. Visible = true
| self. fm = DispatchWithEvents (self. fm, AcEvents)
| | blows out with
| | self. fm = DispatchWithEvents (self. fm, AcEvents)
| File | "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line | 258, in
| DispatchWithEvents
| clsid = disp_class.CLSID
| AttributeError: 'NoneType' object has no attribute 'CLSID'.
Well, it's not clear from your code, but the third parameter to DispatchWithEvents should be a *class* and not an *instance*. Since AcEvents isn't defined anywhere within your code snippet, it's hard to see which it is, but just in case...
That said, I can't for the life of me see why that would raise the error you're showing, but first things first.
TJG
_______________________________________________________________________
_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32