Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calling VBA Function from VSTO Code

Hi,

I need to call a VBA Function (accepting parameters and returning values)
from a VSTO Add In Code base. The macro code base in the .xlsm file is as
follows :-

Sub SayHelloVBA()
MsgBox "Hello from VBA."
Dim k As Integer
k = tesFn(10, 5)
MsgBox k
End Sub

Public Function tesFn(ByVal i As Integer, ByVal j As Integer) As Integer
tesFn = i + j
End Function

I am able to call the Subroutine SayHelloVBA succesfully from VSTO Using the
following code :-
Globals.ThisWorkbook.Application.Run("Sheet1.SayHe lloVBA")

However, I am not able to call any of the Functions (since, I need return
values from VBA, for which I need functions !)

I have tried the following syntax :-
Dim answer As Integer
answer = Globals.ThisWorkbook.Application.Run("Sheet1.tesFn ", 10, 5)
MsgBox(answer)

However, this is returning zero in the answer variable. Please advice.
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
Addins - Calling an addin function from within VBA code Guy Normandeau Excel Programming 1 June 20th 06 07:22 PM
Calling functions developed in VSTO 2005 from Office Excel 2003 Neil Janabi Excel Programming 0 March 16th 06 10:50 AM
VSTO: calling excel funcions? Lars Schouw Excel Programming 4 October 24th 05 07:31 PM
Calling macros, looping function? Can this code be written more efficiently? Punsterr Excel Programming 4 October 7th 05 07:16 PM
Calling Match function from code Backslider Excel Programming 2 February 28th 04 03:12 AM


All times are GMT +1. The time now is 08:19 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"