I'm using 'MSScriptControl.ScriptControl' to run scripts that are stored in a SQL-Database.
The scripts all have a "run" function as a interface to my Application (MSExcel VBA) that is using the ScriptControl. After laoding the script this run function is executed ...
Dim oScript As Object: Set oScript = CreateObject("MSScriptControl.ScriptControl")
Dim sScript As String: sScript = getExecScript(sName)
InitScriptControl oScript
On Error Resume Next
oScript.AddCode sScript
If Err.Number <> 0 Then
MsgBox oScript.Error.Description & " at Line: " & m_Src(oScript.Error.Line - 1) & vbNewLine & "Near: " & oScript.Error.text
Else
If IsMissing(aParameters) Then
oScript.Run "run"
Else
oScript.Run "run", aParameters
End If
If Err.Number <> 0 Then
MsgBox oScript.Error.Description & " at Line: " & oScript.Error.Line & vbNewLine & "Near: " & oScript.Error.text
End If
End If
On Error GoTo 0
... the 2nd MsgBox line usually is shown when a run-time error occurs.
My Problem is the when this error actually is within a Class-Method the
error-line-number is not from within the class it is usually indicated as inside the run-function where the class method is called.
e.g.
Error Line indicated by Script Control:
oDL.downloadRec oRec, oRng
Actual Error:
Public Sub downloadRec(oRec, oRange)
If R_TitleFlag Then
End Sub
What can I do to receive the correct Error Line?