• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Freeze a workbook until a condition is met

Badbax

New Member
I have a workbook (Excel 2007) that I want to prevent users doing anything with until a button is pressed. The said button is to "Accept Terms of Use" and failure to accept will keep the workbook frozen. I have tried assigning a macro to the button and doing a hyperlink to a "dead" cell; I have tried storing some text in a hidden cell to test; and I have tried various Fx but these do not work either.

I have a second button with an assigned macro that resets user variable data in the entire workbook, when this is clicked I want the terms of use to also be reset, forcing the user to re-click to "Accept Terms of Use" again. If this query is clear perhaps someone can help me. Oh, I am not a VB guru either. Cheers and thanks
 
This is similar to a classic problem of "how to make sure user enables macros?". My suggestion would be to setup a worksheet that acts as a "cover page". Have nothing on this sheet other than than terms you want the user to accept, and the button.

Now, when you go to "reset"the workbook, we'll make all the other worksheets very hidden (this is a VB setting, so you can't even use Format - Unhide to get to the sheets). The button will be assigned a seperate macro that unhides everything. The two macros are:

[pre]
Code:
'Make sure you change the name of "Main Sheet" to
'whatever worksheet your Terms & conditions are on

Sub AcceptTerms()
For Each ws In ThisWorkbook.Worksheets
ws.Visible = -1 ' code for visible
Next
Worksheets("Main Sheet").Visible = 2
End Sub

Sub ResetWorkbook()
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Main Sheet" Then
ws.Visible = 2 'code for very hidden
Else
ws.Visible = -1
End If
Next ws
End Sub
[/pre]
 
Whoever you are Luke M I tried your solution. Thank you, it works fine. I tweaked it a little to suit my needs and although I am not a VB developer I managed to get it to work. Cheers
 
Back
Top