+ Reply to Thread
Results 1 to 6 of 6

Running a macro Upon Closing

Hybrid View

Guest Running a macro Upon Closing 01-28-2005, 08:06 PM
Guest RE: Running a macro Upon... 01-28-2005, 08:06 PM
Guest Re: Running a macro Upon... 01-28-2005, 08:06 PM
Guest Re: Running a macro Upon... 01-28-2005, 10:06 PM
Guest Re: Running a macro Upon... 01-29-2005, 03:06 AM
Guest Re: Running a macro Upon... 01-29-2005, 08:06 AM
  1. #1
    Confused Excel Fan
    Guest

    Running a macro Upon Closing

    I have figured out the code to run Excel in Full Screen mode and get it to
    have a "non excel" look to it. I want to run the reverse code however upon
    closing excel. What code should I use to get a macro to run as I close the
    program down.
    Private Sub Workbook_Close() ???
    Private Sub Auto_Close() ???

    Or somethine entirely different. Thanks!
    Chris

  2. #2
    Jim Thomlinson
    Guest

    RE: Running a macro Upon Closing

    Auto Close is a little older that workbook close but they both function
    exactly the same. The advantage to auto close is that you can place it in a
    modue and export it for later use. But either way is just fine...

    HTH

    "Confused Excel Fan" wrote:

    > I have figured out the code to run Excel in Full Screen mode and get it to
    > have a "non excel" look to it. I want to run the reverse code however upon
    > closing excel. What code should I use to get a macro to run as I close the
    > program down.
    > Private Sub Workbook_Close() ???
    > Private Sub Auto_Close() ???
    >
    > Or somethine entirely different. Thanks!
    > Chris


  3. #3
    Harald Staff
    Guest

    Re: Running a macro Upon Closing

    Hi Chris

    Adding: You should imo use the parallell to what you use on opening, for the
    sake of symmetry and consistence.

    But test what happens if you're prompted "save changes ?" and you select
    Cancel. The file stays open but the macro has already done its job. So you
    must have your code deal with this before it does its real job.

    HTH. Best wishes Harald

    "Confused Excel Fan" <Confused Excel Fan@discussions.microsoft.com> skrev i
    melding news:ECF62D4B-17A7-4A59-B795-FA18924C2CF9@microsoft.com...
    > I have figured out the code to run Excel in Full Screen mode and get it to
    > have a "non excel" look to it. I want to run the reverse code however

    upon
    > closing excel. What code should I use to get a macro to run as I close

    the
    > program down.
    > Private Sub Workbook_Close() ???
    > Private Sub Auto_Close() ???
    >
    > Or somethine entirely different. Thanks!
    > Chris




  4. #4
    Still confused Excel Fan...
    Guest

    Re: Running a macro Upon Closing

    I guess my basic problem is that I can't figure out how to get a macro to
    automatically run as I close down excel. I figured out how to have some code
    run at the opening, and I want all of it to be reversed as I shut it
    down...So, I want all the changes I made to be undone as I close the
    program. Im just now sure what kind of code, or where to put the code in the
    first place. For some reason, the way excel is set up at my work, If I was
    just to run the code that puts it into full screen mode, and gets rid of all
    menus...even if I close excel it and don't save any changes, the code seems
    to be applie to any other excel worksheet I open. This is the reson I want
    to reverse the code everytime this particular excel sheet closes down.
    Thanks for the replies so far!
    Chris

  5. #5
    gocush
    Guest

    Re: Running a macro Upon Closing

    Try the following of some thing like it

    In ThisWorkbook module:

    Private Sub Workbook_Open()
    Application.DisplayFullScreen=True

    ' Other formatting code
    End sub


    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.DisplayFullScreen=False
    'Code to reverse other formatting
    End Sub

    "Still confused Excel Fan..." wrote:

    > I guess my basic problem is that I can't figure out how to get a macro to
    > automatically run as I close down excel. I figured out how to have some code
    > run at the opening, and I want all of it to be reversed as I shut it
    > down...So, I want all the changes I made to be undone as I close the
    > program. Im just now sure what kind of code, or where to put the code in the
    > first place. For some reason, the way excel is set up at my work, If I was
    > just to run the code that puts it into full screen mode, and gets rid of all
    > menus...even if I close excel it and don't save any changes, the code seems
    > to be applie to any other excel worksheet I open. This is the reson I want
    > to reverse the code everytime this particular excel sheet closes down.
    > Thanks for the replies so far!
    > Chris


  6. #6
    Harald Staff
    Guest

    Re: Running a macro Upon Closing

    Hi Chris

    Apolgogies for this: It's like "I know how to make a left turn with my car,
    but I can't figure our how to make a right turn" -no harm intended.

    Here's some useful theory:
    http://www.cpearson.com/excel/events.htm
    note that there's a big difference between opening/closing Excel and
    opening/closing your spesific file. For Excel herself see
    http://www.cpearson.com/excel/AppEvent.htm

    Sounds like you're making a "dictator app" for Excel. Consider carefully
    what will happen if the user wants to work with several Excel files
    simoultaneously, that is very common. Maybe your changes should happen when
    you activate/deactivate your file, not on open/close.

    HTH. Best wishes Harald

    "Still confused Excel Fan..." <Still confused Excel
    Fan...@discussions.microsoft.com> skrev i melding
    news:4E822F25-C66D-4DFA-9991-E1F85B7EB557@microsoft.com...
    > I guess my basic problem is that I can't figure out how to get a macro to
    > automatically run as I close down excel. I figured out how to have some

    code
    > run at the opening, and I want all of it to be reversed as I shut it
    > down




+ 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