try
{
excelApplication.Run(macroName);
}
catch (Exception)
{
message = string.Format("Error executing macro {0}.", macroName);
}
As you have seen you can't catch the return from the vba function . If you have control over the macro then put in an error handler and save any err value in some object accessible from excel dna like a defined name MyErr.
If it's other people's code that has no error handling then you're out of luck.
var macroResult =string.Empty;
macroResult = excelApplication.Run(macroName);
Function GenerateError()
On Error GoTo ErrorHandler
Dim i As Integer
i = 8 / 0#
GenerateError = ""
Exit Function
ErrorHandler:
GenerateError = Err.Number & " - " & Err.Description
End Function
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at http://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.