Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Addins - Calling an addin function from within VBA code | Excel Programming | |||
Calling functions developed in VSTO 2005 from Office Excel 2003 | Excel Programming | |||
VSTO: calling excel funcions? | Excel Programming | |||
Calling macros, looping function? Can this code be written more efficiently? | Excel Programming | |||
Calling Match function from code | Excel Programming |