unprotecting excel worksheet
Hello
I have got this worksheet which does not open normally in windows explorer since it is protected.
i tried to unprotect it from the excel bars but the option was greyed out
i was wondering if i could write some VB code which would unprotect the file and then i could view it normally
Re: unprotecting excel worksheet
Are we talking sheet or workbook? If the sheet is only protected then you can open the file with no issues but may
only be able to edit the non-protected sheets.
If its protected at the workbook level then you need a passwrod to unprotect it before opening it.
Re: unprotecting excel worksheet
I think your talking Workbook protection so here is a sample.
VB Code:
Option Explicit
'Add a reference to MS Excel xx.0 Object Linrary
Private Sub Command1_Click()
Dim oApp As Excel.Application
Dim oWB As Excel.Workbook
Set oApp = New Excel.Application
oApp.Visible = True
Set oWB = oApp.Workbooks.Open("C:\Book1.xls")
oWB.Unprotect "Password"
'Do your stuff
'...
'...
oWB.Close True 'Save changes
Set oWB = Nothing
oApp.Quit
Set oApp = Nothing
End Sub
Re: unprotecting excel worksheet