+ Reply to Thread
Results 1 to 2 of 2

Save method and BeforeSave event

Hybrid View

  1. #1
    mikelee101@hotmail.com
    Guest

    Save method and BeforeSave event

    Greetings,
    I have a workbook that, before saving, I want to activate a specific
    cell. The following works most of the time:
    ==========
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
    Boolean)

    Call SelectEntryDate

    End Sub
    ==========
    The procedure it calls is:
    ==========
    Sub SelectEntryDate()

    On Error Resume Next
    ThisWorkbook.Names("entry.date").RefersToRange.Select
    On Error GoTo 0

    End Sub
    ==========

    The only time that it fails that I haven't been able to fix is when I
    use a "Save All" routine in personal.xls. That routine is as
    follows:

    ==========
    Sub SaveAllBooks()
    Dim WkBk As Workbook

    Application.ScreenUpdating = False

    For Each WkBk In Application.Workbooks
    WkBk.Save
    Next WkBk

    Application.ScreenUpdating = True

    End Sub
    ==========

    The workbook saves, but it doesn't select the range. My questions,
    therefore, are; Does the save method somehow bypass the beforesave
    event? If so, is there a way to make it work? I've tried removing the
    ScreenUpdating lines, but it didn't help.

    Excel 2000, XP Pro

    Thanks to all for the input.

    Mike


  2. #2
    Norman Jones
    Guest

    Re: Save method and BeforeSave event

    Hi Mike,

    Try amending the SaveAllBooks macro to:

    Sub SaveAllBooks()
    Dim WkBk As Workbook
    Dim WBactive As Workbook

    Set WBactive = ActiveWorkbook

    Application.ScreenUpdating = False

    For Each WkBk In Application.Workbooks
    If WkBk.Name = "TEST1.xls" Then '<<===== CHANGE
    WkBk.Activate
    Application.Run (WkBk.Name & "!SelectEntryDate")
    End If

    WkBk.Save

    Next WkBk

    WBactive.Activate

    Application.ScreenUpdating = True

    End Sub
    '==========

    Change TEST1.xls to the name of the problematic workbook.

    ---
    Regards,
    Norman



    <mikelee101@hotmail.com> wrote in message
    news:1121395040.708006.144670@f14g2000cwb.googlegroups.com...
    > Greetings,
    > I have a workbook that, before saving, I want to activate a specific
    > cell. The following works most of the time:
    > ==========
    > Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
    > Boolean)
    >
    > Call SelectEntryDate
    >
    > End Sub
    > ==========
    > The procedure it calls is:
    > ==========
    > Sub SelectEntryDate()
    >
    > On Error Resume Next
    > ThisWorkbook.Names("entry.date").RefersToRange.Select
    > On Error GoTo 0
    >
    > End Sub
    > ==========
    >
    > The only time that it fails that I haven't been able to fix is when I
    > use a "Save All" routine in personal.xls. That routine is as
    > follows:
    >
    > ==========
    > Sub SaveAllBooks()
    > Dim WkBk As Workbook
    >
    > Application.ScreenUpdating = False
    >
    > For Each WkBk In Application.Workbooks
    > WkBk.Save
    > Next WkBk
    >
    > Application.ScreenUpdating = True
    >
    > End Sub
    > ==========
    >
    > The workbook saves, but it doesn't select the range. My questions,
    > therefore, are; Does the save method somehow bypass the beforesave
    > event? If so, is there a way to make it work? I've tried removing the
    > ScreenUpdating lines, but it didn't help.
    >
    > Excel 2000, XP Pro
    >
    > Thanks to all for the input.
    >
    > Mike
    >




+ 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