Forum Discussion

pampalond's avatar
2 years ago

Calling external unit.routine using variable1.variable2

Hello everyone.


I have a little problem with the following:




I have an Excel spreadsheet that containing functions and sub-functions


1Run?Tarteted Main Functions to TestTargeted Sub Function to Test


I have this code:


Dim Excel, RowCount, ColumnCount, i, j, s, isRun, functionName, subFunctionName


Set Excel = Sys.OleObject("Excel.Application")
Excel.Workbooks.Open("C:\TestComplete 15 Projects\Data_Files\A01_Test_Setup.xlsx")


RowCount = Excel.ActiveSheet.UsedRange.Rows.Count
ColumnCount = Excel.ActiveSheet.UsedRange.Columns.Count


For i = 2 To RowCount           'Start at 2nd row since I use the first row as headers

For j = 1 To ColumnCount

if j = 1 then

isRun = VarToString(Excel.Cells(i,j))
if isRun = "y" then

functionName = VarToString(Excel.Cells(i,j+1))            'Assign Excel cell B2 value to functionName 
subFunctionName = VarToString(Excel.Cells(i,j+2))     'Assign Excel cell C2 value to subfunctionName


'At this point, I would like to use the Call statement using the variables functionName and subfunctionName as follows:


Call functionName.subFunctionName


'of course, I know the Call statement will not work as is but I am asking if there is another way to accomplish this.


End if

End If





Thanks in advance for your help.

1 Reply

  • rraghvani's avatar
    Champion Level 3

    Use GetRef() method. For example,


    Function F(p)
        F = p + p
    End Function
    Dim FP : Set FP = GetRef("F")
    WScript.Echo FP("a")
    WScript.Echo FP(123)