Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Removing Password using VBA

Dear NG,

Please help me. I am trying to remove the "password to open a workbook"
using the code below. Although, it runs well during execution and does not
show any error messages, when I try to manually open my workbooks, it still
ask for password.

TIA

Jon-jon

Sub RemoveOpenPassword(myFilepath As String, myFilename As String, _
myOpenPassword As String, myWritePassword As String)
Dim Wb As Workbook
Set Wb = Workbooks.Open(Filename:=myFilepath & "\" & myFilename,
Password:=myOpenPassword, _
WriteResPassword:=myWritePassword, AddToMru:=False)
With Wb
.Password = ""
.Close True
End With
Set Wb = Nothing
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Removing Password using VBA

Jon,
Excel2K anyway does not have a .Password property, so I can't test it.
Try SavingAs the WB without a password.

NickHK

"JON JON" wrote in message
...
Dear NG,

Please help me. I am trying to remove the "password to open a workbook"
using the code below. Although, it runs well during execution and does

not
show any error messages, when I try to manually open my workbooks, it

still
ask for password.

TIA

Jon-jon

Sub RemoveOpenPassword(myFilepath As String, myFilename As String, _
myOpenPassword As String, myWritePassword As String)
Dim Wb As Workbook
Set Wb = Workbooks.Open(Filename:=myFilepath & "\" & myFilename,
Password:=myOpenPassword, _
WriteResPassword:=myWritePassword, AddToMru:=False)
With Wb
.Password = ""
.Close True
End With
Set Wb = Nothing
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Removing Password using VBA

Thank you for the reply!

I have tried your suggestion and still does not work. BTW, I'm using XP.

This is my revised code

Sub RemoveOpenPassword(myFilepath As String, myFilename As String, _
myOpenPassword As String, myWritePassword As String)
Dim Wb As Workbook
Set Wb = Workbooks.Open(Filename:=myFilepath & "\" & myFilename,
Password:=myOpenPassword, _
WriteResPassword:=myWritePassword, AddToMru:=False)
With Wb
Application.DisplayAlerts = False
.SaveAs Filename:=.FullName, FileFormat:=xlNormal,
WriteResPassword:=myWritePassword, AddToMru:=False
Application.DisplayAlerts = True
.Close True
End With
Set Wb = Nothing
End Sub



"NickHK" wrote in message
...
Jon,
Excel2K anyway does not have a .Password property, so I can't test it.
Try SavingAs the WB without a password.

NickHK

"JON JON" wrote in message
...
Dear NG,

Please help me. I am trying to remove the "password to open a workbook"
using the code below. Although, it runs well during execution and does

not
show any error messages, when I try to manually open my workbooks, it

still
ask for password.

TIA

Jon-jon

Sub RemoveOpenPassword(myFilepath As String, myFilename As String, _
myOpenPassword As String, myWritePassword As String)
Dim Wb As Workbook
Set Wb = Workbooks.Open(Filename:=myFilepath & "\" & myFilename,
Password:=myOpenPassword, _
WriteResPassword:=myWritePassword, AddToMru:=False)
With Wb
.Password = ""
.Close True
End With
Set Wb = Nothing
End Sub






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Removing Password using VBA

Jon,
In the SaveAs, set the password to "".

NickHK

"JON JON" wrote in message
...
Thank you for the reply!

I have tried your suggestion and still does not work. BTW, I'm using XP.

This is my revised code

Sub RemoveOpenPassword(myFilepath As String, myFilename As String, _
myOpenPassword As String, myWritePassword As String)
Dim Wb As Workbook
Set Wb = Workbooks.Open(Filename:=myFilepath & "\" & myFilename,
Password:=myOpenPassword, _
WriteResPassword:=myWritePassword, AddToMru:=False)
With Wb
Application.DisplayAlerts = False
.SaveAs Filename:=.FullName, FileFormat:=xlNormal,
WriteResPassword:=myWritePassword, AddToMru:=False
Application.DisplayAlerts = True
.Close True
End With
Set Wb = Nothing
End Sub



"NickHK" wrote in message
...
Jon,
Excel2K anyway does not have a .Password property, so I can't test it.
Try SavingAs the WB without a password.

NickHK

"JON JON" wrote in message
...
Dear NG,

Please help me. I am trying to remove the "password to open a

workbook"
using the code below. Although, it runs well during execution and does

not
show any error messages, when I try to manually open my workbooks, it

still
ask for password.

TIA

Jon-jon

Sub RemoveOpenPassword(myFilepath As String, myFilename As String, _
myOpenPassword As String, myWritePassword As String)
Dim Wb As Workbook
Set Wb = Workbooks.Open(Filename:=myFilepath & "\" & myFilename,
Password:=myOpenPassword, _
WriteResPassword:=myWritePassword, AddToMru:=False)
With Wb
.Password = ""
.Close True
End With
Set Wb = Nothing
End Sub








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Removing Password using VBA

I don't know how the unprotect command affect the open password but it does
seem the cause of my problem. Below is the final code. Also, I should
add that the Save command is also needed befire resetting the protection.

Nick, I really appreciate how you had tried to help.

Till next time

Regards,

Jon-jon


Sub RemoveOpenPassword(myFilepath As String, myFilename As String, _
myOpenPassword As String, myWritePassword As String)
Dim Wb As Workbook
Set Wb = Workbooks.Open(Filename:=myFilepath & "\" & myFilename,
Password:=myOpenPassword, _
WriteResPassword:=myWritePassword, AddToMru:=False)
With Wb
.Unprotect "myPassword"
.Password = ""
.Save
.Protect "myPassword"
.Close True
End With
Set Wb = Nothing
End Sub

"NickHK" wrote in message
...
Jon,
In the SaveAs, set the password to "".

NickHK

"JON JON" wrote in message
...
Thank you for the reply!

I have tried your suggestion and still does not work. BTW, I'm using
XP.

This is my revised code

Sub RemoveOpenPassword(myFilepath As String, myFilename As String, _
myOpenPassword As String, myWritePassword As String)
Dim Wb As Workbook
Set Wb = Workbooks.Open(Filename:=myFilepath & "\" & myFilename,
Password:=myOpenPassword, _
WriteResPassword:=myWritePassword, AddToMru:=False)
With Wb
Application.DisplayAlerts = False
.SaveAs Filename:=.FullName, FileFormat:=xlNormal,
WriteResPassword:=myWritePassword, AddToMru:=False
Application.DisplayAlerts = True
.Close True
End With
Set Wb = Nothing
End Sub



"NickHK" wrote in message
...
Jon,
Excel2K anyway does not have a .Password property, so I can't test it.
Try SavingAs the WB without a password.

NickHK

"JON JON" wrote in message
...
Dear NG,

Please help me. I am trying to remove the "password to open a

workbook"
using the code below. Although, it runs well during execution and
does
not
show any error messages, when I try to manually open my workbooks, it
still
ask for password.

TIA

Jon-jon

Sub RemoveOpenPassword(myFilepath As String, myFilename As String, _
myOpenPassword As String, myWritePassword As String)
Dim Wb As Workbook
Set Wb = Workbooks.Open(Filename:=myFilepath & "\" & myFilename,
Password:=myOpenPassword, _
WriteResPassword:=myWritePassword, AddToMru:=False)
With Wb
.Password = ""
.Close True
End With
Set Wb = Nothing
End Sub












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
removing password protection AllieR Excel Discussion (Misc queries) 1 March 17th 09 03:41 PM
Removing a password grizzly6969 Excel Discussion (Misc queries) 3 January 22nd 09 01:24 AM
removing excel sheet password nag New Users to Excel 2 April 9th 08 09:32 PM
Removing an open file password protection Dollster Excel Worksheet Functions 0 November 24th 06 03:21 PM
Removing Excel password. Kris Excel Programming 4 October 14th 04 03:22 AM


All times are GMT +1. The time now is 10:38 PM.

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

About Us

"It's about Microsoft Excel"