Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default VBA, UDFs and VSTO

Terence,

Some suggestions only, as your objManaged.calcExpense(row, col, begcol, begqtr, endqtr, begsal)
makes no sense to me. (calcExpense is a property of objManaged???)

1. The first argument "row" should be a Long not an Integer - there are 65000 + rows in excel.
2. Do not use "row" as a variable, it is a key word in Excel.
3. The IsEmpty functions are useless, they will always return False.
IsEmpty only returns meaningful information for Variants and range objects.
Instead try something like...
If row * col * begcol = 0 Then exit Function

That ought to get you started.

Regards,
Jim Cone
San Francisco, CA

"Terence Craig" <Terence wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA, UDFs and VSTO

Jim,

Thanks for the response. I will try your suggestions:

Regarding the objmanaged object that is the codebehind (COM) object created
by my VSTO project. calcExpense is a member function of that code behind
object.



Regards,

Terence


"Jim Cone" wrote:

Terence,

Some suggestions only, as your objManaged.calcExpense(row, col, begcol, begqtr, endqtr, begsal)
makes no sense to me. (calcExpense is a property of objManaged???)

1. The first argument "row" should be a Long not an Integer - there are 65000 + rows in excel.
2. Do not use "row" as a variable, it is a key word in Excel.
3. The IsEmpty functions are useless, they will always return False.
IsEmpty only returns meaningful information for Variants and range objects.
Instead try something like...
If row * col * begcol = 0 Then exit Function

That ought to get you started.

Regards,
Jim Cone
San Francisco, CA

"Terence Craig" <Terence wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA, UDFs and VSTO

I have made all of Jim's suggested changes and still have the problem.

Would appreciate any additional advice.

Thanks Terence

"Terence Craig" wrote:

Jim,

Thanks for the response. I will try your suggestions:

Regarding the objmanaged object that is the codebehind (COM) object created
by my VSTO project. calcExpense is a member function of that code behind
object.



Regards,

Terence


"Jim Cone" wrote:

Terence,

Some suggestions only, as your objManaged.calcExpense(row, col, begcol, begqtr, endqtr, begsal)
makes no sense to me. (calcExpense is a property of objManaged???)

1. The first argument "row" should be a Long not an Integer - there are 65000 + rows in excel.
2. Do not use "row" as a variable, it is a key word in Excel.
3. The IsEmpty functions are useless, they will always return False.
IsEmpty only returns meaningful information for Variants and range objects.
Instead try something like...
If row * col * begcol = 0 Then exit Function

That ought to get you started.

Regards,
Jim Cone
San Francisco, CA

"Terence Craig" <Terence wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tool tip for the UDFs created using vsto se add-in. parmanand Excel Worksheet Functions 1 March 12th 07 03:42 PM
VSTO David12345 Excel Discussion (Misc queries) 2 December 27th 05 08:14 PM
'portable' UDFs??? whelanj[_7_] Excel Programming 1 July 9th 04 01:13 PM
Acrobat 6.0 and UDFs Mike Lee[_2_] Excel Programming 0 January 29th 04 04:07 PM
VSTO 2.0 No Name Excel Programming 1 December 8th 03 09:02 PM


All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"