+ Reply to Thread
Results 1 to 24 of 24

out of stack space??

  1. #1
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    out of stack space??

    Hi,
    I was working on a program to import data from word tables into excel. Most of the code I got was from internet. When I run it, however, I get an error 28: out of stack space! How do I get rid of this. Is there a way to track stack space? I want to see which procedures from my other macro file use up a lot of stack space.

    See below code and code line where error occurs:
    Please Login or Register  to view this content.
    Thanks, help is much appreciated as always
    Last edited by adds007; 02-17-2011 at 09:43 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: out of stack space??

    Hello adds007,

    Change this line...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    Unfortutely Ross,
    It didn't work. The strange thing is that this program worked fine 2 days ago. Is there a way to track stack? IF there is, i will go through each line to see what;s wrong.
    THanks

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: out of stack space??

    Hello adds007,

    If you are running out of stack space, I suspect this macro is being called from either a Worksheet_Change or Worksheet_SelectionChange event. The most common cause of stack space errors is due to cascade failure. This happens when an Sub or Function is called recursively and does not remove data from the previous call. You should post your workbook to get a quick an accurate answer.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: out of stack space??

    Try:
    Please Login or Register  to view this content.
    Adapt the fullfilename



  6. #6
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    Hello adds007,

    If you are running out of stack space, I suspect this macro is being called from either a Worksheet_Change or Worksheet_SelectionChange event. The most common cause of stack space errors is due to cascade failure. This happens when an Sub or Function is called recursively and does not remove data from the previous call. You should post your workbook to get a quick an accurate answer.
    I am not using any events, so that can;t be the problem. I went through line by line and didnt do anything recursive till the error line atleast. I attached a copy of it for your reference. FYI, it works fine on my co-workers computer. Attached is a copy of the workbook.

    Sub tst()
    With GetObject("E:\OF\0_rain4u table.doc") '<--out of stack space error here
    .tables(1).Range.Copy
    End With
    Sheets(1).Paste
    End Sub
    Unfortunately snb, that didn't work either. Still shows the error for both GetObject and CreateObject.

    I am pretty sure the stack got filled up with another program i am working on. That one is pretty big program and I might have missed something that;s filling up stack. So a way to know how memory gets filled would be nice to know, if you guys know.
    Thanks
    Attached Files Attached Files

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: out of stack space??

    If you do not use the userform and use my code there will be no problem.

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: out of stack space??

    Hello adds007,

    This version of the macro works for me. Give a try and let me know what happens.
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    Hi,
    Sorry for the delay, I can't access my computer on weekends.

    THanks for the program you gave. It worked, but it's really really slow.
    Most of the time the dialog box doesn't open.

    I decided to try what snb told me, and got rid of userform.
    IT WORKED PERFECT, like a charm. Thanks a lot for the advice, snb.
    But sometimes i have to import a huge table and it takes a long time to import. Isnt there anyway to include the userform to show progress without slowing it down?

    Regardless, I am glad i know what the problem is now.

    Thanks snb and Leith Ross for all the feedback and support!

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: out of stack space??

    It's no use using a progress Bar, because it's only 1 instruction that is being given.

    But if you are very impatient you could consider:

    Please Login or Register  to view this content.
    Last edited by snb; 02-14-2011 at 10:47 AM.

  11. #11
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    Snb,
    I just realized about using your 4 lines of code instead of mine like 20 lines of code.
    Yours is way more efficient and doesn't require a progress bar. However, the format after import is not the type i want, unlike the other long procedure I used. Is there a way to improve this program so that no merge cells appear and all cells are copied exacly into excel? In other words, I want your program to give same result as my program.
    That would save a lot of time of having to unmerge and fix all cells manually.
    Thanks

  12. #12
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    I got bad news. The ghost of the past is back to haunt me. "OUT OF STACK SPACE"
    Unfortunately, the error appeared again (which didnt before) at GetObject when I run snb's program. I added the functionality of having the user to select the file.
    Please Login or Register  to view this content.
    please help!

  13. #13
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: out of stack space??

    Why is your sub declared static?
    Remember what the dormouse said
    Feed your head

  14. #14
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    I got that from excel help:

    Your local variables require more local variable space than is available.
    Try declaring some variables at the module level instead. You can also declare all variables in the procedure static by preceding the Property, Sub, or Function keyword with Static. Or you can use the Static statement to declare individual Static variables within procedures.

  15. #15
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: out of stack space??

    I really don't think that is helping you. How are you calling this code in the first place?

  16. #16
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    I will remove static, since you are right, its not helping me
    But this procedure is called upon a form control button click on worksheet. It doesnt refer to any other procedures in the project, also.

  17. #17
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    I put the code in simplest form I could and still gives me that error!
    Attached is a sample of what i have, which gives me an error
    Attached Files Attached Files

  18. #18
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: out of stack space??

    One immediate thing I see is that this:
    Please Login or Register  to view this content.
    should be:
    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    I am sorry, I must have typed it wrong, but that;s not where the error occurs
    It's at GetObject function. is there any other way i can get handle on the word file and copy the table?

  20. #20
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: out of stack space??

    How much memory do you have free before you run this code?

  21. #21
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    I placed below code just before using GetObject
    Please Login or Register  to view this content.
    And this is what it gave me in the immdiate window

    Please Login or Register  to view this content.
    Seems like i have a lot of space left

  22. #22
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: out of stack space??

    Yes but there are memory limits within that as to what Excel will actually use. Do you have any other workbooks open at the time?

  23. #23
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    nope only one workbook is open

  24. #24
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: out of stack space??

    is there a way to check what's on stack right now? or how I can clear it?
    Because, my code is like 10 lines long with abosolutely nothing else open, and gives me the friking error when i run it.
    I mean how can i be out of stack space, when i am running nothing else?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1