![]() |
How to make a button conditional
I have a workbook with several sheets and buttons in them.
This excel-file is shared over a p2p network and is password protected against writing. The idea is, that everyone can consult the file but only some can change it. For changing and for consulting some buttons were programmed. If someone opens the file read-only and tries to make some change via the changing buttons he or she seems to get away with this ... BUT, if the file is then closed, several dialoge messages appear (telling that saving is not allowed and asking if you want to save to a new file). To avoid this, I would like to make functioning of the changing buttons conditional to the writing-password. Hitting the changing buttons in read-only status (so without using the password to open the file) can than result in a simple message telling this operation is not allowed. This should be possible with a IF ... THEN ... ELSE statement. Only, how/where can I get this (status)information (so, whether the file was or wasn't opened using the password that allows writing and changing) and combine it with the code the button refers to? Would appreciate any help on this. Jan V. |
How to make a button conditional
Jan
What kind of buttons are they, Forms toolbar buttons or Control Toolbox buttons. If the latter, you can put code like this in the open event. Private Sub Workbook_Open() Dim oleo As OLEObject If Me.ReadOnly Then For Each oleo In Me.Sheets(1).OLEObjects oleo.Enabled = False Next oleo End If End Sub -- Dick Kusleika MVP - Excel Excel Blog - Daily Dose of Excel www.dicks-blog.com "Jan V." wrote in message ... I have a workbook with several sheets and buttons in them. This excel-file is shared over a p2p network and is password protected against writing. The idea is, that everyone can consult the file but only some can change it. For changing and for consulting some buttons were programmed. If someone opens the file read-only and tries to make some change via the changing buttons he or she seems to get away with this ... BUT, if the file is then closed, several dialoge messages appear (telling that saving is not allowed and asking if you want to save to a new file). To avoid this, I would like to make functioning of the changing buttons conditional to the writing-password. Hitting the changing buttons in read-only status (so without using the password to open the file) can than result in a simple message telling this operation is not allowed. This should be possible with a IF ... THEN ... ELSE statement. Only, how/where can I get this (status)information (so, whether the file was or wasn't opened using the password that allows writing and changing) and combine it with the code the button refers to? Would appreciate any help on this. Jan V. |
How to make a button conditional
Jan,
I'm sorry, I don't have a reply to your question, but I am ver interested in how you set up your p2p in Excel. If you wouldn't mind sharing you code could you send me a copy to tak a look at. If not, thank you anyway. TIA -- Message posted from http://www.ExcelForum.com |
All times are GMT +1. The time now is 01:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com