PC Review


Reply
Thread Tools Rate Thread

How to Cancel the Protect of Excel with VB and save it with a new password again

 
 
NTorch
Guest
Posts: n/a
 
      1st Aug 2008
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



 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      1st Aug 2008
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password Protect so can't save and change Brandy Microsoft Excel Misc 1 4th Sep 2008 12:39 AM
trying to save a document, I get inaccessible or password protect =?Utf-8?B?Q3VybHlnaXJs?= Microsoft Excel Misc 1 30th May 2007 07:52 PM
Password protect content editing vs. password protect open document ?? Camille Petersen Microsoft Word Document Management 1 3rd May 2006 01:25 PM
How can I cancel the password protect field =?Utf-8?B?Sm9obiBT?= Microsoft Access 2 15th Apr 2005 09:47 PM
Excel yes/no/cancel on save window off screen on right Aaron D. Microsoft Excel Crashes 0 26th Mar 2004 02:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:44 AM.