Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default CATCH-22 won't let me save the file

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




  #2   Report Post  
Posted to microsoft.public.excel.programming
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






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default CATCH-22 won't let me save the file

Just to be sure, I re-copied the code from this post. I made sure that E59
was blank (I clicked in the cell and hit the Delete key). When I tried to
close the file, I got a syntax error.
In the VB editor, Lines 1 and 2 (beginning w "Private" and "Cancel") were
highlighted in yellow, and line 5 (beginning w "Range") was selected.
Incidentally, when I first pasted the code into the right-hand pane (after
selecting "ThisWorkbook" in left pane), lines 5 thru 7 appeared in red.
Since I am not a VB programmer, I don't know the significance, if any, of the
points I raise in this paragraph.
I don't know how to turn off events, although now a later response to my
post, from Dave Peterson, provides code to do so, coupled with a coding
suggestion.

I appreciate your taking the time to help!
---Pat

"PCLIVE" wrote:

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






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

When copying the code from the post, be careful of text wrapping.
When you see an underscore ( _ ) following a space in code, this usually
indicates that the code is continued to the next line. Let's see if this
causes a problem.

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



--

"Patrick Riley" wrote in message
...
Just to be sure, I re-copied the code from this post. I made sure that
E59
was blank (I clicked in the cell and hit the Delete key). When I tried to
close the file, I got a syntax error.
In the VB editor, Lines 1 and 2 (beginning w "Private" and "Cancel") were
highlighted in yellow, and line 5 (beginning w "Range") was selected.
Incidentally, when I first pasted the code into the right-hand pane (after
selecting "ThisWorkbook" in left pane), lines 5 thru 7 appeared in red.
Since I am not a VB programmer, I don't know the significance, if any, of
the
points I raise in this paragraph.
I don't know how to turn off events, although now a later response to my
post, from Dave Peterson, provides code to do so, coupled with a coding
suggestion.

I appreciate your taking the time to help!
---Pat

"PCLIVE" wrote:

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








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default CATCH-22 won't let me save the file

Paul:

The Input-Box code worked like a charm, with one blip: When I click "Cancel"
in the Input Box, the Input Box closes (which is expected, and OK), but then
a Save-File window opens, allowing me to save the file without filling in the
name field. (I made sure that the name field truly was blank.)
Does this phenomenon occur when you run the code?

---Pat

"PCLIVE" wrote:

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








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

Ok,

Let's try this. Be careful of wrap-around. With this code, you can close
the sheet leaving E59 blank by typing a key word. In this case, the key
word is "Admin". Of course you can change that.

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

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

If Range("E59").Value = "Admin" _
Then
Range("E59").ClearContents
Exit Sub
Else
End If
Loop

End Sub

--

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

The Input-Box code worked like a charm, with one blip: When I click
"Cancel"
in the Input Box, the Input Box closes (which is expected, and OK), but
then
a Save-File window opens, allowing me to save the file without filling in
the
name field. (I made sure that the name field truly was blank.)
Does this phenomenon occur when you run the code?

---Pat

"PCLIVE" wrote:

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








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default CATCH-22 won't let me save the file

In VB Editor, I widened the right-hand code pane so that the code did not
wrap, that it had exactly the same line arrangement that I received. I chose
to keep "Admin" (with one cap and four lower-case) as the key word.
I made sure that cell E59 was empty. When I ran the macro, I got an error:

Run Time error '1004'
Cannot change part of a merged cell

The result was: cell E59 contained "Admin" (that is, E59 did not get emptied
out).
Cell E59 is a merger of cells that, during the development of the file, were
originally cells E59 thru O59 inclusive. Can't understand why Excel is upset
with a merged cell.
---Pat

"PCLIVE" wrote:

Ok,

Let's try this. Be careful of wrap-around. With this code, you can close
the sheet leaving E59 blank by typing a key word. In this case, the key
word is "Admin". Of course you can change that.

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

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

If Range("E59").Value = "Admin" _
Then
Range("E59").ClearContents
Exit Sub
Else
End If
Loop

End Sub

--

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

The Input-Box code worked like a charm, with one blip: When I click
"Cancel"
in the Input Box, the Input Box closes (which is expected, and OK), but
then
a Save-File window opens, allowing me to save the file without filling in
the
name field. (I made sure that the name field truly was blank.)
Does this phenomenon occur when you run the code?

---Pat

"PCLIVE" wrote:

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









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

Ok. Just expand the range in the line that has ClearContents.

Range("E59:O59").ClearContents

That should do it.


--

"Patrick Riley" wrote in message
...
In VB Editor, I widened the right-hand code pane so that the code did not
wrap, that it had exactly the same line arrangement that I received. I
chose
to keep "Admin" (with one cap and four lower-case) as the key word.
I made sure that cell E59 was empty. When I ran the macro, I got an
error:

Run Time error '1004'
Cannot change part of a merged cell

The result was: cell E59 contained "Admin" (that is, E59 did not get
emptied
out).
Cell E59 is a merger of cells that, during the development of the file,
were
originally cells E59 thru O59 inclusive. Can't understand why Excel is
upset
with a merged cell.
---Pat

"PCLIVE" wrote:

Ok,

Let's try this. Be careful of wrap-around. With this code, you can
close
the sheet leaving E59 blank by typing a key word. In this case, the key
word is "Admin". Of course you can change that.

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

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

If Range("E59").Value = "Admin" _
Then
Range("E59").ClearContents
Exit Sub
Else
End If
Loop

End Sub

--

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

The Input-Box code worked like a charm, with one blip: When I click
"Cancel"
in the Input Box, the Input Box closes (which is expected, and OK), but
then
a Save-File window opens, allowing me to save the file without filling
in
the
name field. (I made sure that the name field truly was blank.)
Does this phenomenon occur when you run the code?

---Pat

"PCLIVE" wrote:

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











  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default CATCH-22 won't let me save the file

Paul:

YES! It worked!!
Thanks so much for your patience throughout the 5 responses that you gave
me. You were generous with your time, and I learned a lot.
---Pat
--------------------
"PCLIVE" wrote:

Ok. Just expand the range in the line that has ClearContents.

Range("E59:O59").ClearContents

That should do it.


--

"Patrick Riley" wrote in message
...
In VB Editor, I widened the right-hand code pane so that the code did not
wrap, that it had exactly the same line arrangement that I received. I
chose
to keep "Admin" (with one cap and four lower-case) as the key word.
I made sure that cell E59 was empty. When I ran the macro, I got an
error:

Run Time error '1004'
Cannot change part of a merged cell

The result was: cell E59 contained "Admin" (that is, E59 did not get
emptied
out).
Cell E59 is a merger of cells that, during the development of the file,
were
originally cells E59 thru O59 inclusive. Can't understand why Excel is
upset
with a merged cell.
---Pat

"PCLIVE" wrote:

Ok,

Let's try this. Be careful of wrap-around. With this code, you can
close
the sheet leaving E59 blank by typing a key word. In this case, the key
word is "Admin". Of course you can change that.

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

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

If Range("E59").Value = "Admin" _
Then
Range("E59").ClearContents
Exit Sub
Else
End If
Loop

End Sub

--

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

The Input-Box code worked like a charm, with one blip: When I click
"Cancel"
in the Input Box, the Input Box closes (which is expected, and OK), but
then
a Save-File window opens, allowing me to save the file without filling
in
the
name field. (I made sure that the name field truly was blank.)
Does this phenomenon occur when you run the code?

---Pat

"PCLIVE" wrote:

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












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
Trying to catch data from a EXCEL file jokobe Excel Discussion (Misc queries) 0 April 21st 08 07:43 PM
Excel Interop Catch Event for Saving a file as xls and as xml? m.ahrens Excel Programming 8 December 29th 04 02:11 PM
Excel marcos firing on file save as but not file save Andy Excel Programming 1 August 3rd 04 10:34 AM
Save File to Another Directory, but not change Users File Save location Mike Knight Excel Programming 1 May 28th 04 09:06 PM
Catch FileSave/Save As/etc... Sonny Maou Excel Programming 4 February 23rd 04 09:47 PM


All times are GMT +1. The time now is 02:46 AM.

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

About Us

"It's about Microsoft Excel"