View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Terence Craig Terence Craig is offline
external usenet poster
 
Posts: 2
Default VBA, UDFs and VSTO

Excel 2003, SP1, Windows XP Pro, SP1 Visual Studio 2003

Hello,


I have created a set of functions in C# that are called by UDFs in Excel
(VBA code below). Most of them work fine but one of them calcExpense fails
at seemingly random intervals:

Public objManaged As Object

Public Sub RegisterCallback(o As Object)
Set objManaged = o
End Sub

Public Function calcExpense(row As Integer, col As Integer, begcol As
Integer, begqtr As String, endqtr As String, begsal As Double) As Double
Application.Volatile
If (IsEmpty(row) Or IsEmpty(col) Or IsEmpty(begcol)) Then
Exit Function
End If
calcExpense = objManaged.calcExpense(row, col, begcol, begqtr, endqtr,
begsal)
End Function

It is called from a cell like so:
calcExpense(ROW(),COLUMN(),COLUMN($F14),$E14,$F14, $D14)

I used a 3rd party tool Cell Audit by cubiclesoft to trace in and it appears
that the intrinsic fucntions ROW and Column are failing before my code is
even called. Causing the VBA function to exit and the cell to be set to
#VALUE.

Whenever the code does actually pass into my C# code the function executes
correctly.


Any help would be appreciated.

Terence