Is it possible to make a field (check box) required before saving a document?
Yes, here's an example with a checkbox named Checkbox1
Put this code in the ThisWorkbook modulePrivate Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheet1.CheckBox1.Value = False Then
Cancel = True
MsgBox quot;Save action cancelledquot; amp; vbCrLf amp; quot;You must check the
checkbox before savingquot;
End IfEnd Sub
If you don't know where the ThisWorkbook module is just reply to this post
and I'll tell you how to get to it.
--
Billy Rogers
Dallas,TX
Currently Using Office 2000quot;Nikkiquot; wrote:
gt; Is it possible to make a field (check box) required before saving a document?
Thank you so much Billy. I thought I knew where the module was, but I guess
I don't. Can you tell me? Thank you!
quot;BillyRogersquot; wrote:
gt; Yes, here's an example with a checkbox named Checkbox1
gt; Put this code in the ThisWorkbook module
gt;
gt;
gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
gt;
gt; If Sheet1.CheckBox1.Value = False Then
gt; Cancel = True
gt; MsgBox quot;Save action cancelledquot; amp; vbCrLf amp; quot;You must check the
gt; checkbox before savingquot;
gt; End If
gt;
gt;
gt; End Sub
gt;
gt; If you don't know where the ThisWorkbook module is just reply to this post
gt; and I'll tell you how to get to it.
gt; --
gt; Billy Rogers
gt;
gt; Dallas,TX
gt;
gt; Currently Using Office 2000
gt;
gt;
gt; quot;Nikkiquot; wrote:
gt;
gt; gt; Is it possible to make a field (check box) required before saving a document?
Press Alt F11 and then on the left side of the screen should be the Project
Exlporer that says quot;Project -VBAProjectquot; at the top. If you don't see it,
click view on the menu and select project explorer. There may be more than
one project. Make sure you select the project with the same name as your
workbook. If you click the plus sign to expand the project (it may already
be expanded) you will see quot;Sheet1quot;, quot;Sheet2quot;, quot;Sheet3quot;, and quot;This Workbookquot;.
Double Click where it says quot;This Workbookquot; and then past the code into the
code window to the right and click the save button.
Make sure actually have a checkbox on the worksheetand that it's named
Checkbox1Billy Rogers
Dallas,TX
Currently Using Office 2000quot;Nikkiquot; wrote:
gt; Thank you so much Billy. I thought I knew where the module was, but I guess
gt; I don't. Can you tell me? Thank you!
gt;
gt; quot;BillyRogersquot; wrote:
gt;
gt; gt; Yes, here's an example with a checkbox named Checkbox1
gt; gt; Put this code in the ThisWorkbook module
gt; gt;
gt; gt;
gt; gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
gt; gt;
gt; gt; If Sheet1.CheckBox1.Value = False Then
gt; gt; Cancel = True
gt; gt; MsgBox quot;Save action cancelledquot; amp; vbCrLf amp; quot;You must check the
gt; gt; checkbox before savingquot;
gt; gt; End If
gt; gt;
gt; gt;
gt; gt; End Sub
gt; gt;
gt; gt; If you don't know where the ThisWorkbook module is just reply to this post
gt; gt; and I'll tell you how to get to it.
gt; gt; --
gt; gt; Billy Rogers
gt; gt;
gt; gt; Dallas,TX
gt; gt;
gt; gt; Currently Using Office 2000
gt; gt;
gt; gt;
gt; gt; quot;Nikkiquot; wrote:
gt; gt;
gt; gt; gt; Is it possible to make a field (check box) required before saving a document?
I am not having any luck. It is letting me save the document with a false
value. The code I used:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheet1.CheckBox1.Value = False Then
Cancel = True
MsgBox quot;Save action cancelledquot; amp; vbCrLf amp; quot;You must check the checkbox
before savingquot;
End If
Is that right? Sorry to be a pain!
quot;BillyRogersquot; wrote:
gt; Press Alt F11 and then on the left side of the screen should be the Project
gt; Exlporer that says quot;Project -VBAProjectquot; at the top. If you don't see it,
gt; click view on the menu and select project explorer. There may be more than
gt; one project. Make sure you select the project with the same name as your
gt; workbook. If you click the plus sign to expand the project (it may already
gt; be expanded) you will see quot;Sheet1quot;, quot;Sheet2quot;, quot;Sheet3quot;, and quot;This Workbookquot;.
gt; Double Click where it says quot;This Workbookquot; and then past the code into the
gt; code window to the right and click the save button.
gt;
gt; Make sure actually have a checkbox on the worksheetand that it's named
gt; Checkbox1
gt;
gt;
gt; Billy Rogers
gt;
gt; Dallas,TX
gt;
gt; Currently Using Office 2000
gt;
gt;
gt; quot;Nikkiquot; wrote:
gt;
gt; gt; Thank you so much Billy. I thought I knew where the module was, but I guess
gt; gt; I don't. Can you tell me? Thank you!
gt; gt;
gt; gt; quot;BillyRogersquot; wrote:
gt; gt;
gt; gt; gt; Yes, here's an example with a checkbox named Checkbox1
gt; gt; gt; Put this code in the ThisWorkbook module
gt; gt; gt;
gt; gt; gt;
gt; gt; gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
gt; gt; gt;
gt; gt; gt; If Sheet1.CheckBox1.Value = False Then
gt; gt; gt; Cancel = True
gt; gt; gt; MsgBox quot;Save action cancelledquot; amp; vbCrLf amp; quot;You must check the
gt; gt; gt; checkbox before savingquot;
gt; gt; gt; End If
gt; gt; gt;
gt; gt; gt;
gt; gt; gt; End Sub
gt; gt; gt;
gt; gt; gt; If you don't know where the ThisWorkbook module is just reply to this post
gt; gt; gt; and I'll tell you how to get to it.
gt; gt; gt; --
gt; gt; gt; Billy Rogers
gt; gt; gt;
gt; gt; gt; Dallas,TX
gt; gt; gt;
gt; gt; gt; Currently Using Office 2000
gt; gt; gt;
gt; gt; gt;
gt; gt; gt; quot;Nikkiquot; wrote:
gt; gt; gt;
gt; gt; gt; gt; Is it possible to make a field (check box) required before saving a document?
I GOT IT!! Just had to add quot;end subquot; Thank you so much! This will help us
tremendously!
quot;Nikkiquot; wrote:
gt; I am not having any luck. It is letting me save the document with a false
gt; value. The code I used:
gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
gt;
gt; If Sheet1.CheckBox1.Value = False Then
gt; Cancel = True
gt; MsgBox quot;Save action cancelledquot; amp; vbCrLf amp; quot;You must check the checkbox
gt; before savingquot;
gt; End If
gt;
gt; Is that right? Sorry to be a pain!
gt;
gt; quot;BillyRogersquot; wrote:
gt;
gt; gt; Press Alt F11 and then on the left side of the screen should be the Project
gt; gt; Exlporer that says quot;Project -VBAProjectquot; at the top. If you don't see it,
gt; gt; click view on the menu and select project explorer. There may be more than
gt; gt; one project. Make sure you select the project with the same name as your
gt; gt; workbook. If you click the plus sign to expand the project (it may already
gt; gt; be expanded) you will see quot;Sheet1quot;, quot;Sheet2quot;, quot;Sheet3quot;, and quot;This Workbookquot;.
gt; gt; Double Click where it says quot;This Workbookquot; and then past the code into the
gt; gt; code window to the right and click the save button.
gt; gt;
gt; gt; Make sure actually have a checkbox on the worksheetand that it's named
gt; gt; Checkbox1
gt; gt;
gt; gt;
gt; gt; Billy Rogers
gt; gt;
gt; gt; Dallas,TX
gt; gt;
gt; gt; Currently Using Office 2000
gt; gt;
gt; gt;
gt; gt; quot;Nikkiquot; wrote:
gt; gt;
gt; gt; gt; Thank you so much Billy. I thought I knew where the module was, but I guess
gt; gt; gt; I don't. Can you tell me? Thank you!
gt; gt; gt;
gt; gt; gt; quot;BillyRogersquot; wrote:
gt; gt; gt;
gt; gt; gt; gt; Yes, here's an example with a checkbox named Checkbox1
gt; gt; gt; gt; Put this code in the ThisWorkbook module
gt; gt; gt; gt;
gt; gt; gt; gt;
gt; gt; gt; gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
gt; gt; gt; gt;
gt; gt; gt; gt; If Sheet1.CheckBox1.Value = False Then
gt; gt; gt; gt; Cancel = True
gt; gt; gt; gt; MsgBox quot;Save action cancelledquot; amp; vbCrLf amp; quot;You must check the
gt; gt; gt; gt; checkbox before savingquot;
gt; gt; gt; gt; End If
gt; gt; gt; gt;
gt; gt; gt; gt;
gt; gt; gt; gt; End Sub
gt; gt; gt; gt;
gt; gt; gt; gt; If you don't know where the ThisWorkbook module is just reply to this post
gt; gt; gt; gt; and I'll tell you how to get to it.
gt; gt; gt; gt; --
gt; gt; gt; gt; Billy Rogers
gt; gt; gt; gt;
gt; gt; gt; gt; Dallas,TX
gt; gt; gt; gt;
gt; gt; gt; gt; Currently Using Office 2000
gt; gt; gt; gt;
gt; gt; gt; gt;
gt; gt; gt; gt; quot;Nikkiquot; wrote:
gt; gt; gt; gt;
gt; gt; gt; gt; gt; Is it possible to make a field (check box) required before saving a document?
I've finally got the error message to appear on the document, but now I can't
save the document without the checkbox marked. How do I get around that???
quot;BillyRogersquot; wrote:
gt; Press Alt F11 and then on the left side of the screen should be the Project
gt; Exlporer that says quot;Project -VBAProjectquot; at the top. If you don't see it,
gt; click view on the menu and select project explorer. There may be more than
gt; one project. Make sure you select the project with the same name as your
gt; workbook. If you click the plus sign to expand the project (it may already
gt; be expanded) you will see quot;Sheet1quot;, quot;Sheet2quot;, quot;Sheet3quot;, and quot;This Workbookquot;.
gt; Double Click where it says quot;This Workbookquot; and then past the code into the
gt; code window to the right and click the save button.
gt;
gt; Make sure actually have a checkbox on the worksheetand that it's named
gt; Checkbox1
gt;
gt;
gt; Billy Rogers
gt;
gt; Dallas,TX
gt;
gt; Currently Using Office 2000
gt;
gt;
gt; quot;Nikkiquot; wrote:
gt;
gt; gt; Thank you so much Billy. I thought I knew where the module was, but I guess
gt; gt; I don't. Can you tell me? Thank you!
gt; gt;
gt; gt; quot;BillyRogersquot; wrote:
gt; gt;
gt; gt; gt; Yes, here's an example with a checkbox named Checkbox1
gt; gt; gt; Put this code in the ThisWorkbook module
gt; gt; gt;
gt; gt; gt;
gt; gt; gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
gt; gt; gt;
gt; gt; gt; If Sheet1.CheckBox1.Value = False Then
gt; gt; gt; Cancel = True
gt; gt; gt; MsgBox quot;Save action cancelledquot; amp; vbCrLf amp; quot;You must check the
gt; gt; gt; checkbox before savingquot;
gt; gt; gt; End If
gt; gt; gt;
gt; gt; gt;
gt; gt; gt; End Sub
gt; gt; gt;
gt; gt; gt; If you don't know where the ThisWorkbook module is just reply to this post
gt; gt; gt; and I'll tell you how to get to it.
gt; gt; gt; --
gt; gt; gt; Billy Rogers
gt; gt; gt;
gt; gt; gt; Dallas,TX
gt; gt; gt;
gt; gt; gt; Currently Using Office 2000
gt; gt; gt;
gt; gt; gt;
gt; gt; gt; quot;Nikkiquot; wrote:
gt; gt; gt;
gt; gt; gt; gt; Is it possible to make a field (check box) required before saving a document?
And if users choose to disable macros when they open the workbook, what then?
A whole 'nother can of worm-like creatures will appear.Gord Dibben MS Excel MVP
On Fri, 4 Aug 2006 14:13:01 -0700, Nikki gt;
wrote:
gt;I've finally got the error message to appear on the document, but now I can't
gt;save the document without the checkbox marked. How do I get around that???
gt;
gt;quot;BillyRogersquot; wrote:
gt;
gt;gt; Press Alt F11 and then on the left side of the screen should be the Project
gt;gt; Exlporer that says quot;Project -VBAProjectquot; at the top. If you don't see it,
gt;gt; click view on the menu and select project explorer. There may be more than
gt;gt; one project. Make sure you select the project with the same name as your
gt;gt; workbook. If you click the plus sign to expand the project (it may already
gt;gt; be expanded) you will see quot;Sheet1quot;, quot;Sheet2quot;, quot;Sheet3quot;, and quot;This Workbookquot;.
gt;gt; Double Click where it says quot;This Workbookquot; and then past the code into the
gt;gt; code window to the right and click the save button.
gt;gt;
gt;gt; Make sure actually have a checkbox on the worksheetand that it's named
gt;gt; Checkbox1
gt;gt;
gt;gt;
gt;gt; Billy Rogers
gt;gt;
gt;gt; Dallas,TX
gt;gt;
gt;gt; Currently Using Office 2000
gt;gt;
gt;gt;
gt;gt; quot;Nikkiquot; wrote:
gt;gt;
gt;gt; gt; Thank you so much Billy. I thought I knew where the module was, but I guess
gt;gt; gt; I don't. Can you tell me? Thank you!
gt;gt; gt;
gt;gt; gt; quot;BillyRogersquot; wrote:
gt;gt; gt;
gt;gt; gt; gt; Yes, here's an example with a checkbox named Checkbox1
gt;gt; gt; gt; Put this code in the ThisWorkbook module
gt;gt; gt; gt;
gt;gt; gt; gt;
gt;gt; gt; gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
gt;gt; gt; gt;
gt;gt; gt; gt; If Sheet1.CheckBox1.Value = False Then
gt;gt; gt; gt; Cancel = True
gt;gt; gt; gt; MsgBox quot;Save action cancelledquot; amp; vbCrLf amp; quot;You must check the
gt;gt; gt; gt; checkbox before savingquot;
gt;gt; gt; gt; End If
gt;gt; gt; gt;
gt;gt; gt; gt;
gt;gt; gt; gt; End Sub
gt;gt; gt; gt;
gt;gt; gt; gt; If you don't know where the ThisWorkbook module is just reply to this post
gt;gt; gt; gt; and I'll tell you how to get to it.
gt;gt; gt; gt; --
gt;gt; gt; gt; Billy Rogers
gt;gt; gt; gt;
gt;gt; gt; gt; Dallas,TX
gt;gt; gt; gt;
gt;gt; gt; gt; Currently Using Office 2000
gt;gt; gt; gt;
gt;gt; gt; gt;
gt;gt; gt; gt; quot;Nikkiquot; wrote:
gt;gt; gt; gt;
gt;gt; gt; gt; gt; Is it possible to make a field (check box) required before saving a document?Nikki,
What exactly is it you are trying to do? Maybe i can help if I understand
what you are trying to do a little better. Do you want the workbook to open
with the checkbox unchecked? and then require that it be checked before it is
closed?
You could comment out the code to save it but then it won't be active when
you open it.
Why do they need to check this box before saving it? What does the
checkbox signify?
Gord,
quot;And if users choose to disable macros when they open the workbook, what
then?quot;
I don't what the point of that comment is. Totally stupid. Can't you say
this about any macro that someone writes? People are here for help and
suggestions. Tell her a better way if you know one. I just offered her the
limited help that I am able to with the small amount of experiece I have.
--
Billy Rogers
Dallas,TX
Currently Using Office 2000 quot;Nikkiquot; wrote:
gt; I've finally got the error message to appear on the document, but now I can't
gt; save the document without the checkbox marked. How do I get around that???
gt;
gt; quot;BillyRogersquot; wrote:
gt;
gt; gt; Press Alt F11 and then on the left side of the screen should be the Project
gt; gt; Exlporer that says quot;Project -VBAProjectquot; at the top. If you don't see it,
gt; gt; click view on the menu and select project explorer. There may be more than
gt; gt; one project. Make sure you select the project with the same name as your
gt; gt; workbook. If you click the plus sign to expand the project (it may already
gt; gt; be expanded) you will see quot;Sheet1quot;, quot;Sheet2quot;, quot;Sheet3quot;, and quot;This Workbookquot;.
gt; gt; Double Click where it says quot;This Workbookquot; and then past the code into the
gt; gt; code window to the right and click the save button.
gt; gt;
gt; gt; Make sure actually have a checkbox on the worksheetand that it's named
gt; gt; Checkbox1
gt; gt;
gt; gt;
gt; gt; Billy Rogers
gt; gt;
gt; gt; Dallas,TX
gt; gt;
gt; gt; Currently Using Office 2000
gt; gt;
gt; gt;
gt; gt; quot;Nikkiquot; wrote:
gt; gt;
gt; gt; gt; Thank you so much Billy. I thought I knew where the module was, but I guess
gt; gt; gt; I don't. Can you tell me? Thank you!
gt; gt; gt;
gt; gt; gt; quot;BillyRogersquot; wrote:
gt; gt; gt;
gt; gt; gt; gt; Yes, here's an example with a checkbox named Checkbox1
gt; gt; gt; gt; Put this code in the ThisWorkbook module
gt; gt; gt; gt;
gt; gt; gt; gt;
gt; gt; gt; gt; Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
gt; gt; gt; gt;
gt; gt; gt; gt; If Sheet1.CheckBox1.Value = False Then
gt; gt; gt; gt; Cancel = True
gt; gt; gt; gt; MsgBox quot;Save action cancelledquot; amp; vbCrLf amp; quot;You must check the
gt; gt; gt; gt; checkbox before savingquot;
gt; gt; gt; gt; End If
gt; gt; gt; gt;
gt; gt; gt; gt;
gt; gt; gt; gt; End Sub
gt; gt; gt; gt;
gt; gt; gt; gt; If you don't know where the ThisWorkbook module is just reply to this post
gt; gt; gt; gt; and I'll tell you how to get to it.
gt; gt; gt; gt; --
gt; gt; gt; gt; Billy Rogers
gt; gt; gt; gt;
gt; gt; gt; gt; Dallas,TX
gt; gt; gt; gt;
gt; gt; gt; gt; Currently Using Office 2000
gt; gt; gt; gt;
gt; gt; gt; gt;
gt; gt; gt; gt; quot;Nikkiquot; wrote:
gt; gt; gt; gt;
gt; gt; gt; gt; gt; Is it possible to make a field (check box) required before saving a document?
Feedback is always appreciated.
Thanks, Gord
On Fri, 4 Aug 2006 20:38:02 -0700, BillyRogers
gt; wrote:
gt;Nikki,
gt;
gt;What exactly is it you are trying to do? Maybe i can help if I understand
gt;what you are trying to do a little better. Do you want the workbook to open
gt;with the checkbox unchecked? and then require that it be checked before it is
gt;closed?
gt;You could comment out the code to save it but then it won't be active when
gt;you open it.
gt;
gt;Why do they need to check this box before saving it? What does the
gt;checkbox signify?
gt;
gt;
gt;
gt;Gord,
gt;quot;And if users choose to disable macros when they open the workbook, what
gt;then?quot;
gt;
gt;I don't what the point of that comment is. Totally stupid. Can't you say
gt;this about any macro that someone writes? People are here for help and
gt;suggestions. Tell her a better way if you know one. I just offered her the
gt;limited help that I am able to with the small amount of experiece I have.
Gord Dibben MS Excel MVP
- Jul 25 Fri 2008 20:45
Required selection
close
全站熱搜
留言列表
發表留言