View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
LRay67 LRay67 is offline
external usenet poster
 
Posts: 49
Default WorkbookBeforeSave Event - check required fields before saving

I am not very good with code, I am trying to Save a workbook, but prior to
saving I want it to check certain fields to ensure they are filled in. Below
is the code I am using, but doesn't seem to work. Any Suggestions??

Linda


Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel As Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbYes Then SaveAsUI = True
If TextBox8 = "" Then
MsgBox "Please enter Submitting Agency Name"
Exit Sub
End If
If TextBox1 = "" Then
MsgBox "Please enter Accounting Unit Code (7 Digits)"
Exit Sub
End If
If TextBox4 = "" Then
MsgBox "Please enter Task Coordinator Name"
Exit Sub
End If
If TextBox5 = "" Then
MsgBox "Please enter Task Coordinator Telephone Number"
Exit Sub
End If
If TextBox6 = "" Then
MsgBox "Please enter Task Coordinator Email Address"
Exit Sub
End If
End Sub