Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9

Thread: Exit Macro help

  1. #1
    Join Date
    Aug 2005
    Location
    London, England
    Posts
    461
    Tokens
    0

    Default Exit Macro help

    I'm trying to create a macro that will save and exit an EXCEL 2007 Wookbook but I'm having problems doing it. I can make it save but I cannot get it to quit without an error occuring.
    Anyway to get around it and make it save and exit without problems?

  2. #2
    Join Date
    Nov 2007
    Posts
    660
    Tokens
    0

    Default

    It may come to help us, if we know which error that is?
    On an assumed conclusion, i'd believe it might be a firewall error, although that should mean the program would not run.

  3. #3
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    As zeJosh said, without knowing what error your getting its hard to make suggestions?

  4. #4
    Join Date
    Nov 2007
    Posts
    660
    Tokens
    0

    Default

    As i've said.
    His firewall might be blocking the file type he's saving,
    causing errors with the main executed program.

  5. #5
    Join Date
    Aug 2005
    Location
    London, England
    Posts
    461
    Tokens
    0

    Default

    The error isn't my firewall. I don't use the program at home because I don't have Office, only Word2007.
    The macro runs but excel closes with an error "Microsoft Excel has encourtered a problem and needs to close".
    I think it's because I'm typing the code incorrectely in the VB script.I have limited knowledge in coding (HTML is the only thingI knowbut vaguely) so I don't know what I can type in the VB macro editing.

  6. #6
    Join Date
    Nov 2006
    Location
    Bradford
    Posts
    2,667
    Tokens
    99

    Latest Awards:

    Default

    if i remember rightly, all you need is "application.exit" along with the other parts of the code for the function you want to make the macro carry out.

    what you may need to do, is loop it so that it doesnt try doing both at the same time.

    i.e you need to make the code to tell the 'macro'..."save the worksheet, once saved, exit Excel"

    its been well over 2 years since i last used VB properly so i cannot tell you the exact code to use
    Rep Points: 1065
    Last Good Rep From: Cyndia
    Last Bad Rep From: someone too cowardly to leave their name



    The People I Trust:
    Royal, Cwmbran, base, :Jakey, Destiny, Laurae90, Evolution, Mik, deagle

  7. #7
    Join Date
    Aug 2005
    Location
    London, England
    Posts
    461
    Tokens
    0

    Default

    Any code I try doesn't seem to work. all of them come back with that "Microsoft Excel has encourtered a problem" error.

    I've tried:

    Sub Save_Exit
    ThisWorkbook.close SaveChanges:=True
    End Sub

    Sub Save_Exit ()
    Wookbooks(filename).close SaveChanges:=True
    End Sub

    but all of them when run comes back with the error

  8. #8
    Join Date
    Aug 2005
    Location
    Newcastle
    Posts
    1,417
    Tokens
    0

    Latest Awards:

    Default

    Try:

    Code:
    Sub Save_Exit()
         Application.Quit
         ThisWorkbook.Close SaveChanges:=True
    End Sub
    Quite a while since I worked with macro's in Excel.



  9. #9
    Join Date
    Aug 2005
    Location
    London, England
    Posts
    461
    Tokens
    0

    Default

    I tried to use that code but excel errors when closing. I thought I had a solution but that errors after a few attempts. It works at first but stops working later on. I put the Application.Quit under ActiveWrokbook.Save (I made a save macro and added the application.quit line under it) but I don't want the system closing every other open workbook.
    I'm not sure why it keeps erroring.

Posting Permissions

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