Ver 7.5.4.2
I have this code:
Sub GetSet
On Error GoTo line5
line5:
MsgBox "Error"
Exit Sub
Dim iTT As Double
Dim TVL As Double
Dim RUN As Double
Dim TOPANGLE As Double
Dim oActiveSheet As Object
Dim oCellRangeByName As Object
Dim oCellRangeBydeg As Object
Dim oCellRun As Object
Dim oCellTopAngle As Object
Rem Gets the Active sheet
oActiveSheet = ThisComponent.getCurrentController().getActiveSheet()
Rem Gets access to a cell
oCellRangeByName = oActiveSheet.getCellRangeByName("G11")
Rem Get Value of cell
iTT = oCellRangeByName.Value
oCellRangeBydeg = oActiveSheet.getCellRangeByName("D14")
DG = oCellRangeBydeg.Value
TVL = iTT*1 / sin(DG * Pi / 180)
Rem Get Value of cell
iTT = oCellRangeByName.Value
oCelld9 = oActiveSheet.getCellRangeByName("D9")
oCelld9.setValue(TVL)
MsgBox(iTT)
'added============================================
RUN = iTT*1 / tan(DG * Pi / 180)
oCellRun = oActiveSheet.getCellRangeByName("D16")
oCellRun.setValue(RUN)
'======================
TOPANGLE = 90 - DG
oCellTopAngle = oActiveSheet.getCellRangeByName("E10")
oCellTopAngle.setValue(TOPANGLE)
'ErrorHandler:
'MsgBox "Error " & Err & ": " & Error$ + chr(13) + "At line : " + Erl + chr(13) + Now , 16 ,"an error occurred"
'Exit Sub
'MsgBox "All files will be closed", 0, "Error"
'added============================================
End Sub
With no error handler it runs fine.
When I added a
On Error GoTo ErrorHandler
It displayed:
Error 0:
At line : 0
So as you can see I added:
On Error GoTo line5
line5:
MsgBox "Error"
Exit Sub
It goes to that and exits. When the handler is at bottom, it all runs, but still shows the error message.
How can there be an error that early in the sub, it’s as though it catching a non error anyway.
Please hep me figure it out. Note line5: is just a name I picked, I don’t mean the actual line 5.