User must agree to User Agreement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please be advised that I am a bit new to the "more advanced" programming.

I am seeking help with programing a workbook where a user must agree with a
disclaimer before the workbook will either:

1) File to open to the disclaimer worksheet only, and then only allow user
to enter other worksheets within the workbook after the user agrees to a
disclaimer. -Preferred-

2) File will not open until they click to agree to a disclaimer.

Thanks in advance
 
You can accomplish #1 in the following manner. First, put your
disclaimer text on a worksheet named "Disclaimer". Then, hide all
other worksheets, so that only Disclaimer is visible. In the
ThisWorkbook code module, put the following code:

Private Sub Worksheet_Open()
If MsgBox("Do you agree to the disclaimer?",vbYesNo) = vbNo
Then
ThisWorkbook.Close savechanges:=False
End If
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
If WS.Name <> "Disclaimer"
WS.Visible = xlVeryHidden
End If
Next WS
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Hi, Chip:

In the Open event procedure, didn't you omit the lines to unhide the
worksheets if the user agrees?

Myrna
 
Yeah, I forgot those.

Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
WS.Visible = True
Next WS


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
I have one sheet named "Data" that I want to keep hidden. All others should
become visible except the "Data" worksheet. What is the code for that?

I am obviously very new to this type programming. I have to ask, "Does this
code go into a Macro?" Sorry to prove my ignorance.

I will play with it until I get it figured out.
Thanks,
Paul
(e-mail address removed)
 
The modify that section to:

For Each WS In ThisWorkbook.Worksheets
If WS.Name <> "Data" Then WS.Visible = True
Next WS

All of the code goes into the Worksheet_Open event in the module named
ThisWorkbook.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top