rowyn: (Me 2012)
[personal profile] rowyn

Hrmph. My report gets through about 10 iterations, then crashes with a stack-overflow error. Which appears to be caused by Excel VBA call stack filling up with my auto-generated macro calls. Googling about for "how to clear the call stack" has not made me optimistic about my odds of getting around this via VBA.  x.x

Date: 2015-04-28 09:15 pm (UTC)
From: [identity profile] level-head.livejournal.com
It may be that your procedure is calling itself. If that's the case, you can have a parent procedure that calls the child one over and over, so the child one exits each time and clears its stack.

===|==============/ Keith DeHavelle

Date: 2015-04-28 09:31 pm (UTC)
From: [identity profile] level-head.livejournal.com
Is the first-called event exiting before it's triggered again? Perhaps, instead of taking off again, it can set a condition in a shared variable and exit, and that shared variable tells the parent procedure to call the child procedure again?

If it's still in the child procedure when it's triggered again, I can see why the system is eventually recursing at you. ];-)

===|==============/ Keith DeHavelle

Date: 2015-04-28 09:32 pm (UTC)
From: [identity profile] tuftears.livejournal.com
I wonder if that's where it's being considered a loop? That is:

1. Data refresh event fires
2. Script saves data under new file name and initiates new batch
3. New batch is loaded, but this is still under the script since it is waiting for the return value of the command
4. Data refresh event fires (but inside the first script)
5. Now you have a fresh copy of the script running for the new filename

And so on until it runs out of stack.

If that were the case, what you'd want to do is (I'm not versed in Excel so I dunno) make it so the script explicitly isn't waiting for the 'get different batch' stuff to return, it just fires it off and leaves.


Date: 2015-04-28 09:34 pm (UTC)
From: [identity profile] terrycloth.livejournal.com
Okay, so the problem is probably that the event call doesn't exit until the fetch is complete, which means that all the events are still on the stack until the last one finishes.

Could you move the 'get a new different batch' step into the outer loop, with some sort of delay so that it didn't try to fetch multiple batches concurrently? Or it could wait on a variable that you set in the event handler (checking the variable every X time period until it's true, then fetch a new batch).
Edited Date: 2015-04-28 09:35 pm (UTC)

Date: 2015-04-29 03:17 am (UTC)
From: [identity profile] whitefangedwolf.livejournal.com
It sounds like you need your code logic to look something like the following:
For Each batch_to_fetch In list_of_batches_to_fetch
      'Grab the batch data'
      Do
             'Check if data is refreshed
      Loop While {Data is not refreshed}
      'Save batch under a new filename
Next
Edited Date: 2015-04-29 03:18 am (UTC)

January 2026

S M T W T F S
    12 3
45678910
11121314151617
18 192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 26th, 2026 09:41 am
Powered by Dreamwidth Studios