+ Reply to Thread
Results 1 to 4 of 4

adding before save so it works every time excel opens and with any workbook

  1. #1
    Job
    Guest

    adding before save so it works every time excel opens and with any workbook

    I'm trying to implement a App_WorkbookBeforeSave bit of code, but I don't
    understand how to get it to work for any open workbook and have it work
    anytime excel is opened.

    Cheers!



  2. #2
    gocush
    Guest

    RE: adding before save so it works every time excel opens and with any

    If you are trying to run the event from Workbook B the code needs to be in
    Wbk B.

    However, once you start the code you can you can make things happen to other
    workbooks:


    With Workbooks("A")
    .Sheets("XXX").Range("A1")=5
    .close True
    End With
    Close true
    end sub

    This will change then Save and Close Wbk A, then Save and Close ThisWorkbook.

    "Job" wrote:

    > I'm trying to implement a App_WorkbookBeforeSave bit of code, but I don't
    > understand how to get it to work for any open workbook and have it work
    > anytime excel is opened.
    >
    > Cheers!
    >
    >
    >


  3. #3
    Job
    Guest

    Re: adding before save so it works every time excel opens and with any

    But, it is not possible to have the code in the personal.xls or some other
    place so that the code could be run anytime Excel is open and on any
    workbook?


    "gocush" <gocushNOT_THIS@comcast.net/delete> wrote in message
    news:6BAB57A5-1ABF-4060-BF07-09D440E5B851@microsoft.com...
    > If you are trying to run the event from Workbook B the code needs to be in
    > Wbk B.
    >
    > However, once you start the code you can you can make things happen to
    > other
    > workbooks:
    >
    >
    > With Workbooks("A")
    > .Sheets("XXX").Range("A1")=5
    > .close True
    > End With
    > Close true
    > end sub
    >
    > This will change then Save and Close Wbk A, then Save and Close
    > ThisWorkbook.
    >
    > "Job" wrote:
    >
    >> I'm trying to implement a App_WorkbookBeforeSave bit of code, but I don't
    >> understand how to get it to work for any open workbook and have it work
    >> anytime excel is opened.
    >>
    >> Cheers!
    >>
    >>
    >>




  4. #4
    gocush
    Guest

    Re: adding before save so it works every time excel opens and with

    To my knowledge the Workbook_BeforeSave event has to be in the ThisWorkbook
    module of each workbook that you want it to apply to.

    However, I think you would work around this by:
    Not having a Workbook_BeforeSave event.
    Instead in your Personal.xls have a macro something like:

    Sub SaveMyFile()
    'Enter your Code to do stuff before saving
    ThisWorkbook.Save
    End Sub

    I am not sure if you can set a shortcut key to a macro in Personal.xls but I
    think you can. If so, go to Tools/Macros/Macro select this macro above
    /Options and enter s. This will direct the built-in Ctrl+s to this
    procedure rather than just the normal Save.

    Keep in mind that doing the above will cause this to happen any time you use
    Excel. Are you sure you want that?

    "Job" wrote:

    > But, it is not possible to have the code in the personal.xls or some other
    > place so that the code could be run anytime Excel is open and on any
    > workbook?
    >
    >
    > "gocush" <gocushNOT_THIS@comcast.net/delete> wrote in message
    > news:6BAB57A5-1ABF-4060-BF07-09D440E5B851@microsoft.com...
    > > If you are trying to run the event from Workbook B the code needs to be in
    > > Wbk B.
    > >
    > > However, once you start the code you can you can make things happen to
    > > other
    > > workbooks:
    > >
    > >
    > > With Workbooks("A")
    > > .Sheets("XXX").Range("A1")=5
    > > .close True
    > > End With
    > > Close true
    > > end sub
    > >
    > > This will change then Save and Close Wbk A, then Save and Close
    > > ThisWorkbook.
    > >
    > > "Job" wrote:
    > >
    > >> I'm trying to implement a App_WorkbookBeforeSave bit of code, but I don't
    > >> understand how to get it to work for any open workbook and have it work
    > >> anytime excel is opened.
    > >>
    > >> Cheers!
    > >>
    > >>
    > >>

    >
    >
    >


+ 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