Type mismatch while invoking vba

I’m trying to get number of visible worksheets in a workbook.

This is the vba code:

Sub VisibleSheets(Byref wb as workbook)
Dim sheets as Object = wb.Sheets
Dim count as Integer
count=0
If sheets IsNot Nothing Then
For Each sheet as Object in sheets
if sheet.visible = true then
count=count+1
end if
Next
End If
return count

I use invoke vba and have the code which is above in it. As EntryMethodParameters I am passing {WorkbookName} where WorkbookName is the output of excel application scope activity. I am getting type mismatch error.

get the macro output in any cell reference in excel itself and after macro executes, use read range activity to read the output of macro in a uipath variable and write the same cell as blank…

Greetings @svinjamuri,

Can you elaborate you use case.

use function instead of subroutine

1 Like