| | |
Protect Sheet with VBA
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2004
Posts: 1
Reputation:
Solved Threads: 0
Hi:
I have a workbook that has several sheets. One sheet called FORM is password protected (by me). I have a macro that clears all sheets but when it gets to FORM it prompts for the password (which I don't wan't to give to my users).
Is there a way to pass the password to the sheet as the macro is running?
thanks
I have a workbook that has several sheets. One sheet called FORM is password protected (by me). I have a macro that clears all sheets but when it gets to FORM it prompts for the password (which I don't wan't to give to my users).
Is there a way to pass the password to the sheet as the macro is running?
thanks
•
•
Join Date: Feb 2008
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Hi:
I have a workbook that has several sheets. One sheet called FORM is password protected (by me). I have a macro that clears all sheets but when it gets to FORM it prompts for the password (which I don't wan't to give to my users).
Is there a way to pass the password to the sheet as the macro is running?
thanks
In project explorer, right click on the modue and select "[module name] properties...". Then click on the protect tab and check lock project for viewing and add a password.
Change yourpassword with any password you want.
' Unprotect the FORM sheet so that VBA can write to it
Sheets("FORM").Unprotect Password:="yourpassword"
' Protect the FORM sheet (change the options after the password to suit your needs)
Sheets("FORM ").Protect Password:="yourpassword", _
DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True
•
•
Join Date: Nov 2009
Posts: 1
Reputation:
Solved Threads: 0
0
#3 28 Days Ago
This simple code will solve your problem.
I assume that sheet1 is your form sheet which you want to protect and only access through code.
sheet1.protect "password", userinterfaceonly:=true
Please note that sheet1 in given in "Microsoft Excel Object" Index in Visual Basic Editor.
Visit my blog if you are willing to download an ebook on Excel.
http://total-ebooks4free.blogspot.com/
I assume that sheet1 is your form sheet which you want to protect and only access through code.
sheet1.protect "password", userinterfaceonly:=true
Please note that sheet1 in given in "Microsoft Excel Object" Index in Visual Basic Editor.
Visit my blog if you are willing to download an ebook on Excel.
http://total-ebooks4free.blogspot.com/
![]() |
Similar Threads
- Run time error '1004' application-defined or object defined error (Visual Basic 4 / 5 / 6)
- Database vs. Spreadsheet (Windows Software)
- Open Excel Sheet in Vb.net (VB.NET)
- Password protection (Visual Basic 4 / 5 / 6)
- VBA - Excel - sheet,range lookup with variables (Visual Basic 4 / 5 / 6)
- My screen keeps shaking no matter what I do. (Apple Hardware)
Other Threads in the VB.NET Forum
- Previous Thread: vb.net, database manipulation
- Next Thread: Issue using Like in VB query to Access DB
| Thread Tools | Search this Thread |
"crystal .net .net2005 2008 access add advanced application array assignment basic beginner box button buttons center click code combo convert cpu data database datagrid datagridview designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall forms html image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net number opacity open pan pdf picturebox picturebox2 port print printpreview record regex reports" reuse right-to-left save savedialog search serial socket sorting sql sqldatbase sqlserver storedprocedure string temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.nettoolboxvisualbasic2008sidebar vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web wpf wrapingcode xml





