excel function in access

mfuada

Registered User.
Local time
Today, 16:44
Joined
Feb 4, 2009
Messages
63
Hi guys i've found a code that seems to me it's calling the excel function to be used in Access vba, i just want to ask u guys the explanation about the code below....
thx


Function PRICEsun(settlement As Date, maturity As Date, rate As Double, yield As Double, principal As Double, freq As Integer, Basis As Variant) As Double

Dim objExcel As Excel.Application
Dim varPrice As Double
Dim vPrice As Double

principal = 100

Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open (objExcel.Application.LibraryPath & _
"\Analysis\ATPVBAEN.XLA")
objExcel.Workbooks("ATPVBAEN.XLA").RunAutoMacros (xlAutoOpen)
vPrice = objExcel.Application.Run("ATPVBAEN.XLA!PRICE", settlement, maturity, rate, yield, principal, freq, Basis)
varPrice = vPrice * 10000

If (RoundU(varPrice) - Round(varPrice, 12)) >= 0.5 Then
varPrice = RoundD(varPrice)
Else
varPrice = RoundU(varPrice)
End If

PRICEsun = varPrice
objExcel.Quit
End Function
 

Users who are viewing this thread

Back
Top Bottom