LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Workbook_BeforeSave

I have a "Workbook_BeforeSave" subroutine (below) that works perfectly
in most PC's, but in my workplace, it only works selectively (only
small bits of the code within the subroutine work). The only bit that
triggers is the "MsgBox" line - everything else is ignored.

Could this be a security setting in my workplace PC's ? (since the
macro works fine on other PC's)

Thanks for your help.

---


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

Application.EnableCancelKey = xlDisabled

'Move cursor to default position
Application.ScreenUpdating = False
Sheets("Data").Select
admin_change = True
Cells(1, 100).Select
admin_change = False
ActiveWindow.ScrollRow = 1: ActiveWindow.ScrollColumn = 1
Display_all 'A subroutine that unhides any hidden cells

'Ensure all fields in "Input" sheet have been duly populated
r = 4
While Sheets("Data").Cells(r, 11).Value < ""
If
Application.WorksheetFunction.CountBlank(Sheets("D ata").Range("B" & r
& ":F" & r)) 0 Then
Cancel = True
Application.ScreenUpdating = True
admin_change = True
Sheets("Data").Range(Cells(r, 1), Cells(r, 11)).Select
'Sheets("Input").Cells(r, 1).EntireRow.Select
admin_change = False
MsgBox "The highlighted record is incomplete." & Chr(13) &
Chr(13) & "Please complete the record thoroughly before saving this
file.", 16, "MIS Incomplete Record"
Exit Sub
End If
r = r + 1
Wend

'Hide sheets
ActiveWorkbook.Unprotect Password:=pro
Sheets("Notice").Visible = True
Sheets("Data").Visible = False
Sheets("Print_buffer").Visible = False
Sheets("Email_buffer").Visible = False
Sheets("Buffer").Visible = False
Sheets("Options").Visible = False
Sheets("Notice").Select
ActiveWorkbook.Protect Password:=pro, Structu=True,
Windows:=False
Application.ScreenUpdating = True

'Restore view
DoEvents
Application.OnTime Now + TimeValue("00:00:01"),
"Restore_view_after_saving"

End Sub
 
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
HELP!!!! Calling a sub from Workbook_BeforeSave RocketMan[_2_] Excel Discussion (Misc queries) 4 May 31st 07 11:47 PM
Workbook_BeforeSave Event Baapi[_21_] Excel Programming 4 July 4th 06 08:54 PM
Workbook_BeforeSave() bmm Excel Programming 3 August 16th 04 03:37 PM
Workbook_BeforeSave Bill Oertell Excel Programming 5 December 21st 03 07:33 PM
Workbook_BeforeSave() in xla Bent Kjeldsen Excel Programming 6 September 24th 03 01:49 PM


All times are GMT +1. The time now is 10:03 PM.

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"