View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
PCLIVE PCLIVE is offline
external usenet poster
 
Posts: 1,311
Default CATCH-22 won't let me save the file

Just to be sure, you are using:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
If IsEmpty(Sheets("Main").Range("E59").Value) _
Then
Range("E59").Value = InputBox("You must type in your name before " &
_
"this file can be saved.", "Enter Name.")
Else
End If
End Sub

Are you sure E59 is currently empty. The code works when I attempt saving.
But if there is a space or anything else in E59, no input box is displayed.
Also, I saw in another post where you were to disable events. Make sure
they are not currently disabled.

Regards.

--

"Patrick Riley" wrote in message
...
Paul:

Thanks for taking the time to respond.
I deleted existing VB code, and used your code. After inserting your
code,
nothing happened:
I could save file with name-field blank. I did not see an input-box
appear.
I saved file and re-opened, and got the same results: no input box, could
still save file with name-field blank.

"PCLIVE" wrote:

Why not just have an input box that will populate the cell?

If IsEmpty(Sheets("Main").Range("E59").Value) _
Then
Range("E59").Value = InputBox("You must type in your name before
" &
_
"this file can be saved.", "Enter Name.")
Else
End If


HTH,
Paul

--

"Patrick Riley" wrote in message
...
Thanks to some generous help from users of this site, I, with no Visual
Basic
knowledge, am using some VB code that requires the user to type his/her
name
into a given cell before the file can be saved, since the name must
appear
on
the printed version. The user-name field is intentionally left blank.
Upon
attempting to save, the code presents a message to type in the name, if
the
name-field is still blank.
Well, CATCH-22. This very code is preventing me from leaving the name
field
blank when I try to save the file in final form, ready for enduser use.
The code I am using is:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
If IsEmpty(Sheets("Main").Range("E59").Value) Then
MsgBox "You must type in your name before " & _
"this file can be saved.", 16, "ERROR"
Cancel = True
End If
End Sub

Any suggestions?
---Pat Riley