Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Cancel the Protect of Excel with VB and save it with a new password again
I need to Open an Excel file with protection password and save it with a new
password again after changing the Excel. Now I know only: Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlsheet As Excel.Worksheet Set xlApp = CreateObject("Excel.Application") xlApp.Visible = True Set xlBook = xlApp.Workbooks.Open("D:\aa.xls", , , , 123) x1Book.Unprotect ("123") Set xlsheet = xlBook.Worksheets(1) xlsheet.Cells(1, 1) = abc xlBook.Close (True) xlApp.Quit But x1Book.Unprotect ("123") is error. And I don't know how to cancel the protect of Excel with VB ;and I don't know how to save it with a new password again after changing the Excel. Any help would be most appreciated. Torch Nee |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to Cancel the Protect of Excel with VB and save it with a newpassword again
Are you running this from excel's VBA?
You can change the password to open by saving it with a new password. You can look at VBA's help for .saveas to see the parms. Or you could use: xlbook.password = "newpassword" xlbook.save xlbook.close false or replace the last two lines with xlbook.close true And (in general) watch your typing. You have xLapp (with an ELL) and x1App (with a one). NTorch wrote: I need to Open an Excel file with protection password and save it with a new password again after changing the Excel. Now I know only: Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlsheet As Excel.Worksheet Set xlApp = CreateObject("Excel.Application") xlApp.Visible = True Set xlBook = xlApp.Workbooks.Open("D:\aa.xls", , , , 123) x1Book.Unprotect ("123") Set xlsheet = xlBook.Worksheets(1) xlsheet.Cells(1, 1) = abc xlBook.Close (True) xlApp.Quit But x1Book.Unprotect ("123") is error. And I don't know how to cancel the protect of Excel with VB ;and I don't know how to save it with a new password again after changing the Excel. Any help would be most appreciated. Torch Nee -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Password Protect so can't save and change | Excel Discussion (Misc queries) | |||
trying to save a document, I get inaccessible or password protect | Excel Discussion (Misc queries) | |||
Cancel 'Password' prompt during VBA | Excel Programming | |||
Password redundant through use of cancel | Excel Discussion (Misc queries) | |||
Cancel Macro is user selects 'cancel' at save menu | Excel Programming |