Click here to Skip to main content
15,888,015 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 ...

VB
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:
VB
oDL.downloadRec oRec, oRng

Actual Error:
VB
Public Sub downloadRec(oRec, oRange)
' ...
  If R_TitleFlag Then
' ...
End Sub  


What can I do to receive the correct Error Line?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900