Microsoft Office Tutorials and References
In Depth Information
Excel data protection
Excel data protection
protection
Microsoft Office Excel provides a few layers of security and protection that allow you
to control the access to an Excel document. VSTO offers a much wider variety of data
and content protection options. One of the important concepts is authentication via
a password request in order to access the data in the workbook. However, there are
no out-of-the-box options available in VSTO to validate the strength of the password
assigned to the workbook or worksheet.
data protection
Workbook protection
protection
The best way of protecting an Excel document is to protect your entire Excel file with
an access password, which will allow only authorized users to view or modify the
data inside the workbook.
Password is a property of the Excel workbook class. You can access this property via
the Globals.ThisWorkbook.Password property. You have more options available
for password encryption when developing a protected Excel solution. Let's take a
look at an example.
Open Visual Studio 2008 and create a new solution, as before. Write the following
code inside the ThisWorkbook.cs file:
private void ThisWorkbook_Startup(object sender,
System.EventArgs e)
{
// Prompting the Textbox to enter the new password for your
workbook
string AuthorPassword = this.Application.
InputBox("New Password:", missing, missing, missing,
missing, missing, missing, missing).ToString();
// Check the Password is not empty
if (AuthorPassword == string.Empty)
{
// If password is empty show message
MessageBox.Show("Please enter valid password");
}
else
{
// Else set the password to the Workbooks password property
Globals.ThisWorkbook.Password = AuthorPassword;
}
}
 
Search JabSto ::




Custom Search