Invocation stack

ElvisSteel

Board Regular
Joined
Mar 23, 2009
Messages
122
Hi,

Not sure if terminology correct, but this is what I need advice on...

I have a workbook that gives the user a start screen (via coding in Workbook_Open) and then carries out a number of steps.

At various stanges they can abort the process and I want to ensure that when this happens they are returned to the start screen.

I can just call the start macro when they abort, but in doing so do I cause a potential memory problem in that I am invoking a call from within a call from within a call etc and this could happen repeatedly.

So a number of questions...

1. Am I worrying unnecessarily?
2. Is there a better way of imposing this type of process?

Thanks

Steve
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I think you're worried about doing this:-
Code:
sub workbook_open()
  call start_screen
end sub
 
sub start_screen()
  [COLOR=green][B]' carry out some stuff[/B][/COLOR]
  if abort_by_user_detected then call workbook_open
end sub
Every time you come out of 'carry out some stuff' with a detected abort condition, you call workbook_open which in turn calls start_screen which might again call workbook_open... each time placing the return address on the stack.

You're right - this will end in tears! Try to contain the looping mechanism within a single procedure, like this:-
Code:
sub workbook_open()
  call start_screen
end sub
 
sub start_screen()
  do
    [B][COLOR=#008000]' carry out some stuff[/COLOR][/B]
  loop until abort_by_user_detected 
end sub

Did I understand the question correctly?
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,121
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top