-1

I have to add error handling code in the scriptwrapper file and the code would be in VB Script. I know try-catch would not work in the VB script. For the Below lines I have to capture the error same like try-catch. So how can I implement this?

wrapper.getVariable( "Efficiency" ).value = excel.range("'Cases'!$H$21")

wrapper.getVariable( "Plant_Price" ).value = excel.range("'Cases'!$H$328")

wrapper.getVariable( "Plant_Price_PerKW" ).value = excel.range("'Cases'!$H$331")

wrapper.getVariable( "Net_Present_Value" ).value = excel.range("'Cases'!$H$782")
Tim Williams
  • 154,628
  • 8
  • 97
  • 125

1 Answers1

1

In VB Script error handling is done by using On Error Resume Next and then checking the Err.Number after your statements.

So:

On Error Resume Next

wrapper.getVariable( "Efficiency" ).value = excel.range("'Cases'!$H$21")

If Err.Number <> 0 Then
  WScript.Echo Err.Description
  Err.Clear
End If



wrapper.getVariable( "Plant_Price" ).value = excel.range("'Cases'!$H$328")

If Err.Number <> 0 Then
  WScript.Echo Err.Description
  Err.Clear
End If

wrapper.getVariable( "Plant_Price_PerKW" ).value = excel.range("'Cases'!$H$331")

If Err.Number <> 0 Then
  WScript.Echo Err.Description
  Err.Clear
End If

wrapper.getVariable( "Net_Present_Value" ).value = excel.range("'Cases'!$H$782")

If Err.Number <> 0 Then
  WScript.Echo Err.Description
  Err.Clear
End If
Alexander Higgins
  • 6,765
  • 1
  • 23
  • 41