Macro not saving my file with a password

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
705
Office Version
  1. 365
Platform
  1. Windows
I have a macro that does all kinds of magic. It's been working fine for years but I need to change it so the file it saves is password protected. I've tried a few things but no dice. Here's the code as is - what can I change to make it save with a password?

ActiveWorkbook.SaveAs Filename:="R:\MyFolder\MyFile.xlsx", CreateBackup:=False
ActiveWorkbook.ChangeFileAccess Mode:=xlReadOnly
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi
You normally set the password whilst working in the workbook.
"Review" tab / "Protect Workbook."
 
Upvote 0
Hi
You normally set the password whilst working in the workbook.
"Review" tab / "Protect Workbook."

Hi
You normally set the password whilst working in the workbook.
"Review" tab / "Protect Workbook."
I can save a file with a password manually when I'm in the file. But - My macro is used by 2 or 3 other people to open a file, manipulate it, then save a copy in a folder for several people to use. The original is file is not saved by the macro and we don't want everybody in the office accessing it - the macro only makes changes and then saves a COPY for 35 people to read. People keep opening that file in edit mode and accidentally making changes. I need the macro to save that copy of the file with a password. I can open that copy and manually save it with a password but that's the only thing I
'm trying to avoid.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

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