Asked by duncanb7
at 2024-06-25 11:14:20
Point:500 Replies:7 POST_ID:828351USER_ID:11059
Topic:
Visual Basic Programming;;Microsoft Excel Spreadsheet Software
I would like to use a signal in subroute or function to quit my program function or sub in VBA Excel 2003 during
looping the main() Sub in whole day.
but it fail because it always exit only on the sub of sub instead of my expectation
that should quit the main sub. Just want to read a signal in other xls file and then quit the main
program when the signal=0. That will let me easily to put break point anywhere in main() to interrupt the program
running during looping main () for whole day. Anyideal to fix the following code , Please advise
I have tried to use xlapp.quit or application.quit acquitsaveall but it still have issue on such command code
Br
Duncan
-------------------------
Fail code as follows:
Sub main ()
'
Call quitprogram 'if signal=0 in instruction.xls at B1, then quit/exit the main sub
'
End Sub
Sub Quitprogram()
Workbooks.Open Filename:= _
"d:instruction.xls"
If Range("b1") = 0 Then
ActiveWorkbook.Close False
Exit Sub 'xlapp.quit or application.quit acquitsaveall that also doesn't work here
Else
ActiveWorkbook.Close False
End Sub
looping the main() Sub in whole day.
but it fail because it always exit only on the sub of sub instead of my expectation
that should quit the main sub. Just want to read a signal in other xls file and then quit the main
program when the signal=0. That will let me easily to put break point anywhere in main() to interrupt the program
running during looping main () for whole day. Anyideal to fix the following code , Please advise
I have tried to use xlapp.quit or application.quit acquitsaveall but it still have issue on such command code
Br
Duncan
-------------------------
Fail code as follows:
Sub main ()
'
Call quitprogram 'if signal=0 in instruction.xls at B1, then quit/exit the main sub
'
End Sub
Sub Quitprogram()
Workbooks.Open Filename:= _
"d:instruction.xls"
If Range("b1") = 0 Then
ActiveWorkbook.Close False
Exit Sub 'xlapp.quit or application.quit acquitsaveall that also doesn't work here
Else
ActiveWorkbook.Close False
End Sub