Thank you Golom and SBerthold. The solution with On Error Resume Next is much better than my "spaghetti code". But it is still four lines of code instead of just one with the desired (but probably impossible) solution.
I have many calls to different functions that may sometimes provoke errors. In a case of an error, I want them to return a default value. This is possible in the following "spaghetti code" example:
Sub MainTest()
a = 1
b = 0
On Error GoTo DivisionErrorHandler
c = a / b
On...
While in Workbook_BeforeSave, is there a way to tell whether the user saves the workbook (via menu File->Save or via the Save button) or whether she uses the menu File->Save As?
I need to execute some actions before the workbook is saved, and these actions depend on the save mode used.
George,
Thank you again for your code. I have played with it and learned a lot. Unfortunately, it would be too difficult to use events in my context, where the application exists already: introducing events would need to reorganize the existing code into class modules and changing methods calls...
dilettante,
This is me that missed something, not you! I missed mentionning that my startup form (which is modal) is a user form in a VBA Excel application. And in Excel (but not in pure VB), you cannot call a modeless form from a modal form (By the way, I do not see why this should be...
George,
Thank you very much for this working example of Events. I am not familiar with them so I appreciate a lot this example which is placed in the context of my present problem.
I am affraid, however, that this does not solve my problem (at least directly). Your solution still needs a form...
I think that at this point I need to explain better the context. I have a method (called "service" hereafter) that makes a lot of calculations, organized in several steps. This service can be called by a user interface (a modal user form) or by a batch. I want that
1) the user be informed which...
The counter on Form1 continues because the timer process started before you click on the cmd button. Here you are right: Form2.Show vbModal does not stop other processes. But it does stop the process that called Form2.Show vbModal.
Try this modification of your example (without the timer)...
Yes, you are right: ShowModal=True comes from Excel VBA UserForms. It has the same effect as calling a form with FormX.Show vbModal.
FormX.Show vbModal DOES stop execution of the program until the FormX is closed. (Otherwise, you are right, other processes are not stopped. I am still able to...
Well, the problem with the solution proposed by mmbsports is that if the message box form is shown as modal (ShowModal=True) then the program stops the execution until the message box is closed (not really what is needed!). On the other hand, if the message box form is made non modal...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.