Jagwarman
asked on
Save file over existing file with password
I use the below code to save a file with a date and a password
ActiveWorkbook.SaveAs Filename:="\\ukancbdata02\ S-gdata\Al lFiles\Rec on\London\ Events\Con solidated Report\Consolidated " & Format(DateAdd("d", -0, Date), "YYYY") & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="pact", _
ReadOnlyRecommended:=True, CreateBackup:=False
What I need to do do is overwrite the file each day but because it is password protected the code returns an error.
Could an Expert provide me with the code that will enable me to save the file each day over the existing file with the password.
ActiveWorkbook.SaveAs Filename:="\\ukancbdata02\
FileFormat:=xlNormal, Password:="", WriteResPassword:="pact", _
ReadOnlyRecommended:=True,
What I need to do do is overwrite the file each day but because it is password protected the code returns an error.
Could an Expert provide me with the code that will enable me to save the file each day over the existing file with the password.
ASKER
Hi Rgonzo, soory not sure I understand the question.
when the original file was saved, it was saved with a password. If I open the file manually I am asked for a password and then I get asked "Open as Read Only?"
So now I want to save over this file.
Does this answer your question?
when the original file was saved, it was saved with a password. If I open the file manually I am asked for a password and then I get asked "Open as Read Only?"
So now I want to save over this file.
Does this answer your question?
I just created a simple file and saved with a password. I then closed the file and tried saving another file with the same name and it gave me the usual "File exists, Replace" warning to which I clicked Yes and the file overwrote with no problem.
Have you closed the original file before trying to Overwrite?
If you are doing changes in the open file which you want to save, just use "ActiveWorkbook.Save" command. The password will be retained for future use.
Thanks
Rob H
Have you closed the original file before trying to Overwrite?
If you are doing changes in the open file which you want to save, just use "ActiveWorkbook.Save" command. The password will be retained for future use.
Thanks
Rob H
ASKER
Hi Rob,
If I open the original file and the save it down its fine.
If I create a new file and call it the same name it does not work.
So maybe it's not possible.
If I open the original file and the save it down its fine.
If I create a new file and call it the same name it does not work.
So maybe it's not possible.
That's exactly what I did. Created file and saved with password. Closed file, created new file and saved with same name, overwrote fine after confirming message.
ASKER
Hi Rob,
when I save outside of a Macro it does exactly what you say. When I try to get the Macro to save it I get error saying the file is Write protected.
when I save outside of a Macro it does exactly what you say. When I try to get the Macro to save it I get error saying the file is Write protected.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Rob thanks for working on this and sorting it.
which PW is missing
ActiveWorkbook.SaveAs Filename:="\\ukancbdata02\
FileFormat:=xlNormal, Password:="", WriteResPassword:="pact", _
ReadOnlyRecommended:=True,
Regards