Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password Protect so can't save and change Brandy Excel Discussion (Misc queries) 1 September 4th 08 12:39 AM
trying to save a document, I get inaccessible or password protect Curlygirl Excel Discussion (Misc queries) 1 May 30th 07 07:52 PM
Cancel 'Password' prompt during VBA Shimmess Excel Programming 7 December 28th 06 03:50 AM
Password redundant through use of cancel Blokeyfella Excel Discussion (Misc queries) 1 February 1st 06 05:00 PM
Cancel Macro is user selects 'cancel' at save menu Mark Excel Programming 1 April 6th 05 05:45 PM


All times are GMT +1. The time now is 04:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"