View Single Post
 
Old 11-18-2013, 06:57 AM
funkyfido funkyfido is offline Windows XP Office 2007
Novice
 
Join Date: Jun 2013
Posts: 24
funkyfido is on a distinguished road
Default Removing a password from a worksheet

Hi
I am using VBA to copy over a range of workbooks to a new location. I want to clear the data from the worksheets which are password protected. I do know the password. Everything works okay until I insert ActiveSheet.Unprotect Password:="Test" then I get a subscript out of range message. Does anyone know how to get around this?
Code:
Sub test()
Workbooks.Open Filename:="c:\Try this.xlsm", Password:="one", WriteResPassword:="two"
 
  ChDir "c:\New\"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\New\Try this 1.xlsm", FileFormat:= _
        xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    
  ActiveSheet.Unprotect Password:="Test"
  
  End Sub
Reply With Quote