Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel command
Message
 
To
10/06/2005 16:33:04
Tim Yoder
Pin Point Computer Systems, Inc.
Bedford Heights, Ohio, United States
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01022321
Message ID:
01022743
Views:
11
>I want to return a calculation from Excel. The problem I am having is that the function is an Excel add-in (analysis toolpack). When I run the following program from foxpro it does not give me the calculation. When I save the file, open Excel, then refresh the formula by pressing F2 and enter it calculates it correctly. Here is the program:
>
>*Get bond yield
>oexcel = createobject("Excel.Application")
>obook = oexcel.workbooks.add()
>
>STORE DATE(2004,11,30) TO ldPurch
>STORE DATE(2028,8,15) TO ldMature
>
>oexcel.activesheet.range("A1").value = "=DATE("+STR(YEAR(ldPurch),4)+","+STR(MONTH(ldPurch),2)+","+STR(DAY(ldPurch),2)+")"
>oexcel.activesheet.range("A2").value = "=DATE("+STR(YEAR(ldMature),4)+","+STR(MONTH(ldMature),2)+","+STR(DAY(ldMature),2)+")"
>oexcel.activesheet.range("A3").value = .055
>oexcel.activesheet.range("A4").value = 106.59375
>oexcel.activesheet.range("A5").value = 100
>oexcel.activesheet.range("A6").value = 2
>oexcel.activesheet.range("A7").value = 0
>
>oexcel.activesheet.range("A8").formula = "=YIELD(A1,A2,A3,A4,A5,A6,A7)"
>
>oexcel.visible = .t.


Try this:
oexcel = createobject("Excel.Application")
obook = oexcel.workbooks.add()

STORE DATE(2004,11,30) TO ldPurch
STORE DATE(2028,8,15) TO ldMature


*** I don't know why Excel wants first Analysis ToolPak to be uninstalled but this works
*** here on mu computer Excel 2003

oexcel.AddIns("Analysis ToolPak").Installed = .f.
oexcel.AddIns("Analysis ToolPak - VBA").Installed = .f.


oexcel.AddIns("Analysis ToolPak").Installed = .t.
oexcel.AddIns("Analysis ToolPak - VBA").Installed = .t.

oexcel.activesheet.range("A1").value = "=DATE("+STR(YEAR(ldPurch),4)+","+STR(MONTH(ldPurch),2)+","+STR(DAY(ldPurch),2)+")"
oexcel.activesheet.range("A2").value = "=DATE("+STR(YEAR(ldMature),4)+","+STR(MONTH(ldMature),2)+","+STR(DAY(ldMature),2)+")"
oexcel.activesheet.range("A3").value = .055
oexcel.activesheet.range("A4").value = 106.59375
oexcel.activesheet.range("A5").value = 100
oexcel.activesheet.range("A6").value = 2
oexcel.activesheet.range("A7").value = 0

oexcel.activesheet.range("A8").formula = "=YIELD(A1,A2,A3,A4,A5,A6,A7)"

oexcel.visible = .t.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform