Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel variables and VFP
Message
From
29/08/2004 14:21:40
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00937401
Message ID:
00937422
Views:
28
>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!

Previous
Reply
Map
View

Click here to load this message in the networking platform