+ Reply to Thread
Results 1 to 8 of 8

Excel crashing/hanging after simple vba commands, help please!!!

  1. #1
    Registered User
    Join Date
    11-05-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Question Excel crashing/hanging after simple vba commands, help please!!!

    Hi everybody
    I have an Excel 2007 worksheet with very simple macros, here are some of them as an example:
    Please Login or Register  to view this content.

    One of the macros also calls up a form for data entry.

    Two problems are driving me crazy!!
    They are mentioned in several internet forums but I haven't found a solution that works for me.

    FIRST PROBLEM:
    =============

    After printing, the macro comes back to the expected worksheet, but:
    - charts & command buttons are not displayed (even though they are still there, I can select them, even click on the buttons and they will work
    - when trying to close the workbook, Excel starts madly refreshing the screen (charts and buttons can be seen and then disappear again in an
    infinte loop) and nothing else happens. It doesn't even respond to Ctrl-Break to interrupt the macro

    If I comment the following line

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

    then the problem doesn't happen, but obviously that's not a viable solution as I need to print!
    I get the same problem with other commands such as PrintPreviw and SetPrintArea

    Here is the macro:
    Please Login or Register  to view this content.

    SECOND PROBLEM:
    ==============

    The Auto_Close routine...

    It runs well when executed thorugh Macros / Run macro
    It runs well when closing the worksheet by clicking on the 'x' button
    It runs well when using the shortcut Ctrl-e associated to a command button on the worksheet
    But when actually clicking on that command button, it runs and does everything as expected, but immediately afterwards Excel crashes.

    It also works well when instead of a form button I use an Activex button, but this shouldn't make any difference!

    Here is the procedure
    Please Login or Register  to view this content.
    I'm at my wits' end! Any help will be appreciated...
    Last edited by Indiana99; 11-10-2010 at 07:52 AM. Reason: Added Code Tags

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Excel crashing/hanging after simple vba commands, help please!!!

    Hi Indiana and welcome to the best Excel forum on the web. Please read the forum rules located at the top of the page. You must rephrase your title and wrap your code in code tags. Once you do that, you'll be sure to get some help.

    Regards
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

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

    Re: Excel crashing/hanging after simple vba commands, help please!!!

    Hello Indiana99,

    Welcome to the Forum!

    To make your posts easier to read, copy, and edit please wrap your code. I did it for you this time. Here is how you can do it next time.

    How to wrap your Code using the # icon
    1. Select all your code using the mouse.
    2. Click on the # icon on the toolbar in the Message window. This will automatically wrap the text you selected with the proper Code tags to create a Code Window in your post.

    To manually wrap your code, use these Bulletin Board Code Tags
    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] After the last line.
    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!)

  4. #4
    Registered User
    Join Date
    11-05-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Excel crashing/hanging after simple vba commands, help please!!!

    Oops sorry about that and thanks!
    In a rush because the deadline for an assignment using these macros is getting close and I'm going crazy... should have read the rules properly anyway
    Also, I've cross posted (again, I found out about this a bit too late)
    The links are

    http://www.mrexcel.com/forum/showthread.php?t=507153
    http://www.mrexcel.com/forum/showthread.php?t=507136

    Thank you

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel crashing/hanging after simple vba commands, help please!!!

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    11-05-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Excel crashing/hanging after simple vba commands, help please!!!

    OK here goes the file, thanks!
    Attached Files Attached Files

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel crashing/hanging after simple vba commands, help please!!!

    I can't see any problems with the code, it runs OK for me

  8. #8
    Registered User
    Join Date
    11-05-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Excel crashing/hanging after simple vba commands, help please!!!

    Yes, I've tried it on a different computer and it runs OK, also if I save it as an Excel 2003 file it works fine. It must clash with some particular setting in the public library computers where I was working; however the code is simple enough and should work whatever the settings. Can't explain what the problem is. Thanks for trying anyway... guess I'll have to cross my fingers and hope it runs on my lecturer's computer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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