Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel variables and VFP
Message
De
29/08/2004 14:21:40
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00937401
Message ID:
00937422
Vues:
25
>Hi, When calling VFP from Excel, can VFP be made aware of variables declared in Excel?
>In the following, the variable theLast is declared in Excel but I get an error -- theLast
>does not exist -- when I try to execute a procedure in VFP -- FormatPri() which starts
>with theLast.
>Thanks
>Steve
>
>Sub FormatPrice
>    Dim oVFP As Object
>    Dim theLast as string  && theLast declared
>    Set oVFP = CreateObject("VisualFoxPro.Application")
>    oVFP.Visible = True
>    oVFP.DoCmd "cd c:\page0\"
>    oVFP.DoCmd "set procedure to c:\page0\FormatPrices.prg"
>    Range("A1").Select
>    theLast = ActiveCell.Value
>    oVFP.DoCmd "FormatPri()"    && Can VFP be aware of the value of theLast
>    ActiveCell.Value = theLast
>    oVFP.Quit
>    Set oVFP = Nothing
>End Sub
>
1. Pass Excel.Application object to VisualFoxPro.Application this way
oVFP.SetVar("Excel", Application)
2. Store value you need to pass to VFP in named Excel cell
3. Then use Excel.Evaluate() in your prg to get named cell's value
4. Dont forget to clean up using:
oVFP.DoCmd("Clear all")
Hope it makes sense to you

P.S. Notice that this way you may also use Excel.ActiveCell.Value in your FoxPro program.
Zlatin Zlatev,
MCSD (VS6)

Make solutions, not programs!

Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform