Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB & Excel gurus, I am trying

Status
Not open for further replies.

bytehead

Programmer
Jul 12, 2001
25
0
0
US
VB & Excel gurus,

I am trying to unprotect an Excel worksheet with no avail. I have recorded a macro in Excel which displays the following code to unprotect the sheet:

ActiveSheet.Unprotect

I have used the object browser in VB to search for unprotect for the proper code in VB to do the same task and have found that the only option available to unprotect a worksheet is Excel.Worksheet.Unprotect ([password]). When this code is used I get "Method or data member not found!".

I also get error "Run Time Error 438, Object does not support this property or method" using the following code:

Private Sub cmdProcess_Click()
Dim ProcLoop As Integer
Dim xlapp As Excel.Application
Set xlapp = New Excel.Application

For ProcLoop = 0 To List1.ListCount - 1
xlapp.Workbooks.Open (List1.List(ProcLoop)), UpdateLinks = 0
xlapp.Worksheet.Unprotect ([wiring])
xlapp.ActiveWorkbook.Save
xlapp.Workbooks.Close
Next ProcLoop

xlapp.Quit
List1.Clear
MsgBox "Done!"
End Sub

Can anyone help?

Regards,

Bytehead
 
Try
xlApp.Worksheet("Worksheet Name").Unprotect

I am not sure but it's worth a shot.

Don't do much excel coding
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top