SaveAs Macro Fails When Workbook has a Password

warriorwoman

New Member
Joined
Mar 18, 2010
Messages
22
I have a macro running that creates a new version on each save and then overwrites a master file. It’s a way to handle version control so that I always have access to the revised versions and the master is always the latest file.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p> </o:p>
It works fine until I introduce password protection to either the versions or the master.<o:p></o:p>
<o:p> </o:p>
I’ve tried using the following but it doesn’t seem to work:<o:p></o:p>
<o:p> </o:p>
.SaveAs MasterFilePath & MasterFileName, FileFormat:=FileFormatNum, WriteResPassword:="password"

I get the error message telling me the file is write-protected.<o:p></o:p>
<o:p> </o:p>
Any help would be appreciated as the password protection is quite important.<o:p></o:p>
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I've just been working on this a bit more and it appears that my code is saving the spreadsheet with the write reserve password of "password".

When I come to run the macro for a second time it fails because it is unable to write over a file with a password.

Is there a way to get around this?
 
Upvote 0

Forum statistics

Threads
1,217,359
Messages
6,136,097
Members
449,991
Latest member
IslandofBDA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top