Hide/Disable/Password Protect ToggleButton1

klarowe

Active Member
Joined
Mar 28, 2011
Messages
389
I was put in charge of developing a new inspection report at my work and as of a few days ago never even knew about macros or anything like that. Through researching online I was finally able to develop 2 macros for hiding/unhiding sensitive information that we do not want the customer to know (ie specific part dimensions). I then assigned those macros to a command toggle button (togglebutton1) so that when pressed in, the text read "customer copy" and certain rows in each sheet were hiddend, and when not pressed in, it read "internal copy" and the rows were visable.

Right now my issue is that if we were to send the customer the report, there is nothing keeping them from being able to press the button I made up... even with the sheet protected, workbook protected, and even if the workbook is saved as a "read-only" document.

So I need a way to either password protect the button, hide the button when the sheet/workbook is protected, or simply disable the button when the sheet/workbook is protected.

Here is the code for the toggle button ("Hide" and "Unhide" are the specific macros for hiding/unhiding the specific rows in each sheet):

Private Sub ToggleButton1_Click()
If ToggleButton1.Caption <> "Customer Copy" Then
ToggleButton1.Caption = "Customer Copy"
CallPressState
Else
ToggleButton1.Caption = "Inernal Copy"
CallPressState
End If
End Sub
Sub CallPressState()
If ToggleButton1.Caption = "Customer Copy" Then
Application.Run "Hide"
Else
Application.Run "Unhide"
End If
End Sub

Any help is greatly appreciated!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Just don't send any sensitive data at all - you could get in trouble, whether it is hidden or not.

Give most of us guys 5 mins and we'll break it and voila - you've leaked sensitive company data.
 
Upvote 0
I have thought about deleting the button and keeping a lock on the VBA so taht it cannot be seen/editted and that may end up being the route I have to take. I was trying to keep it easy for the person sending it to the customer so that they would just simply press the button to change it to customer copy, protect it, save it, and send it.

I know that anyone who really wanted to get the information could, but the information that is given out isn't something extremely sensitive.... we've actually been giving it out on our current reports. Its just more of something that we would rather not have visible. But the big thing is taht they want it all into one single report rather than having to have multiple reports (customer vs. internal)
 
Upvote 0
I will look into saving as a PDF file. That would be the best case scenerio as the customer wouldn't be able to change anything. I had thought about it, but PDF does not show up in the "save-as" window.

Another thing I thought of that might be easier is setting the visibility as a link to the workbook/sheet protection.
Basically:
If workbook (or sheet) protection = true, Then togglebutton1 visibility = false.

Not sure if that is possible or how the code would be written.

Thanks for all the help, it is much appreciated.

Cross-link: http://www.thecodecage.com/forumz/m...on1-sheet-workbook-protection.html#post743991<!-- google_ad_section_end --><!-- / message -->
 
Upvote 0
Problem Solved. With some online help I was able to simply develop 2 command buttons (instead of one toggle). The first button ("customer copy") is just a basic button linked to the "hide" macro. The second button ("internal copy") is password protected and linked to the "unhide" macro.

Here is the code for future references:

Option Explicit
Sub CommandButton1_Click()
Application.Run "Hide"
End Sub
Private Sub CommandButton2_Click()
Const PW As String = "Atlascopco"

If Application.InputBox("Enter password to continue") <> PW Then
MsgBox "Incorrect password", vbCritical, "Cancelled"
Exit Sub
Else:
Application.Run "Unhide"
End If
End Sub

**"Hide" / "Unhide" are macros that I created that hide/unhide specific rows on specific sheets.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top