Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel worksheets in VFP6
Message
 
À
11/01/2000 04:58:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00316031
Message ID:
00316105
Vues:
20
The variable, oExcel in this case, has lost scope. If you ran this code from the command window:
public oleapp,oExcel
gfile=getfile("xls")

If !empty(gfile)
    oExcel = createobject("Excel.Application")
    With oExcel
       .Workbooks.Open(gFile)
       .visible=.t.
    EndWith
Endif
You will see that Excel sticks around. Also, your automation code can be simplified a bit...

If you are doing this in a form, one solution might be this:
gfile=getfile("xls")
If !empty(gfile)
    Thisform.oExcel = createobject("Excel.Application")
    With Thisform.oExcel
       .Workbooks.Open(gFile)
       .visible=.t.
    EndWith
Endif
The key is to make sure the variable that holds a reference to the automation server remains in scope. Otherwise, the instance gets destroyed.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform