Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jon jon is offline
external usenet poster
 
Posts: 6
Default how to protect sheets from VBA?

I need to protect all of the sheets in my AddIn before I release it, but I
don't want them to be protected while I'm doing development. Is there any
way to protect the sheets when the AddIn is loaded, or at some other time?
I'm using Excel 97...

:)

Jon


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to protect sheets from VBA?

Why do you not just password protect the addin?

Or create a simple macro to protect the sheets and unprotect whe
working on them.

i.e place an admin macro in the addin so its locked when others use i
but when you need to ammend something you can click admin and put th
password in which then unlock the sheets.

Below is some code which may help you, or you can use a simple cod
also below
<=====Code that i have found=======

Sub modMenu_Administer()
On Error GoTo err_modMenu_Administer
'vars
Dim strTemp As String

'code
strTemp = InputBox("Please enter password to unlock thi
workbook")
If strTemp = sysCurrentPW Then
sysUnlockWorkbook
Else
If strTemp < "" Then
MsgBox "Password incorrect"
End If
End If

'gotos
exit_modMenu_Administer:
Exit Sub

err_modMenu_Administer:
MsgBox Err & " - " & Error()
Resume exit_modMenu_Administer


End Sub

Sub sysLockWorkbook()
On Error GoTo err_LockWorkbook

'vars

'code
Sheets("Personal Details").Protect sysCurrentPW
Sheets("Log").Protect sysCurrentPW
Sheets("System").Visible = False
Sheets("modSystem").Visible = False
Sheets("modMenu").Visible = False
Sheets("modDetails").Visible = False
Sheets("frmDetails").Visible = False
Sheets("modLog").Visible = False
Sheets("frmLog").Visible = False
Sheets("Lists").Visible = False
Sheets("frmPrint").Visible = False
Sheets("modPrint").Visible = False
Sheets("modOutput").Visible = False
Sheets("frmOutput").Visible = False
Sheets("tmpLog").Visible = False


sysMenusVisible False
sysToolBarsVisible False
'gotos
exit_LockWorkbook:
Exit Sub

err_LockWorkbook:
MsgBox Err & " - " & Error()
Resume exit_LockWorkbook
Resume
End Sub



Sub sysUnlockWorkbook()
On Error GoTo err_UnlockWorkbook

'vars
Dim objToolbar As Object


'code
Sheets("Personal Details").Unprotect sysCurrentPW
Sheets("Log").Unprotect sysCurrentPW
Sheets("System").Visible = True
Sheets("modSystem").Visible = True
Sheets("modMenu").Visible = True
Sheets("modDetails").Visible = True
Sheets("frmDetails").Visible = True
Sheets("modLog").Visible = True
Sheets("frmLog").Visible = True
Sheets("Lists").Visible = True
Sheets("frmPrint").Visible = True
Sheets("modPrint").Visible = True
Sheets("modOutput").Visible = True
Sheets("frmOutput").Visible = True
Sheets("tmpLog").Visible = True

sysMenusVisible True
sysToolBarsVisible True
'gotos
exit_UnlockWorkbook:
Exit Sub

err_UnlockWorkbook:
MsgBox Err & " - " & Error()
Resume exit_UnlockWorkbook

End Su

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protect sheets in one go mohavv Excel Discussion (Misc queries) 4 March 11th 08 10:21 PM
Protect some sheets in an xls but not all. lucky1 Excel Worksheet Functions 0 June 6th 07 09:05 PM
Protect-Unprotect all the sheets Gary Excel Worksheet Functions 7 February 26th 07 08:13 PM
Protect all Sheets Phil Osman Excel Discussion (Misc queries) 0 June 17th 05 01:55 AM
Protect a few sheets Soniya Excel Programming 0 August 27th 03 08:11 AM


All times are GMT +1. The time now is 06:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"