Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add event to excel document
Message
From
08/07/2002 08:57:02
 
 
To
07/07/2002 14:54:42
Charles Richard
Nvo Management Systems
Boisbriand, Quebec, Canada
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00675958
Message ID:
00676079
Views:
14
This message has been marked as the solution to the initial question of the thread.
>I am creating an excel document through automation. I need to add code to the Worksheet_Change event. How can I do this from VFP 7?
>
>Recording a macro doesn't follow through to the VBA editor so I can't see how Excel does it)
>

The piece of the object model you need to examine is VBIDE and its VBComponents collection. I was able to find the code in a Word document with code along these lines:
    LOCAL loComponent AS VBIDE.VBComponent

    WITH THIS.odocument.VBProject
      *************************************************************      * Grab the right module
      *************************************************************      loComponent=.NULL.
      FOR lnComponent = 1 TO .VBComponents.COUNT
        IF UPPER(.VBComponents(lnComponent).NAME) == "THISDOCUMENT"
          loComponent = .VBComponents(lnComponent)
          EXIT
        ENDIF
      ENDFOR

    ENDWITH

    RETURN loComponent
Once you get that far, you want to look at the CodeModule member of the component.

It's pretty brute force, but I was able to replace the code in one document with code from another.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform