i do a fair amount of excel automation work for my client.  this time i would like to use excel as an external editor to compliment the vfp built in grid, i.e. instead of using the grid to edit data, the user can say click a button to start up excel and use excel to edit the data, when they close excel after editing, somehow the edited data will be wrriten back to the grid.  this way the user can use the multi-cell copy and paste feature of excel among other useful features of excel.

in order to do that, i need to trap the excel closing event.  that is doable with the eventhandler call.  all i have to do is to find out which excel interface to bind to by loading the excel type library into vfp object browser.  i picked appevents in excel.application and bind to the appevents_workbookbeforeclose event.  that all works fine until i release it to production.  the eventhandler() call failed complaining an event handler is missing, namely appevents_workbooksync.  i eventually found out that it is because of different version of excel, i have v2002 in my development pc, and the production pcs have v2003.

okay, i tried to copy the excel.exe from a production pc to my development pc and open it up in object browser to check how different the appevents interface is.  when i try to ask vfp to create a skeleton class for me by dragging the appevents node in the object browser to a code window, it errors out with:

"member vartypeinfo does not evaluate to an object."

if i click ignore, then another error:

"variable "lcintcode" is not found.

no code is generated.

so eventually i have to manually code back all the missing event handler in order to make it work with excel 2003.  these functions do not have to do anything as long as they are defined to satisfy the binding call.  these missing event handlers are:


the exact definition of these functions can be found in msdb website.
perhaps i may have to to do all these over again when my client starts to use office 2007...
or perhaps there is a simply way to solve this problem...

One Response to Excel Event Binding

  • I doubt copying the excel.exe will do you any good. Excel requires many more files such as DLL and TLB. If you want to target and test against Office 2003, I suggest you install a full copy of the product on your development pc.

    I use VMWare Server (free download at http://www.vmware.com) for testing against different operating systems and third party software on a virtual machine.

Leave a Reply

Your email address will not be published. Required fields are marked *