Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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.Sel ect
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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



wrote in message
oups.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.Sel ect
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code Problem in BeforeSave Event Kirk P. Excel Programming 3 February 23rd 05 10:08 PM
BeforeSave event Carl Bowman Excel Discussion (Misc queries) 4 February 6th 05 12:28 PM
BeforeSave sub won't save another workbook when triggered by another event sub Brad Yundt Excel Programming 1 June 3rd 04 03:12 AM
BeforeSave event j23 Excel Programming 0 April 6th 04 11:15 AM
BeforeSave workbook event Cindy Excel Programming 15 February 10th 04 04:28 PM


All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"