SaveCopyAs method and read only

OfficeUser

Well-known Member
Joined
Feb 4, 2010
Messages
542
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am using the following vba:
Code:
ActiveWorkbook.SaveCopyAs Filename:="N:\Materials\Testing\Measurements Copy.xls"

I would like to add to this so that the workbook 'Measurements Copy.xls' is Read-Only unless a password is used to allow edits. Can anyone point me in the direction to know how this is accomplished? Thanks!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi
See if this helps:

Code:
Sub CreatePass()
Dim sh As Worksheet
Set sh = ActiveSheet                ' sheet to protect
If Not sh.Cells(1, 1).Locked Then sh.Cells.Locked = True
sh.Protect "iamthepassword"
ActiveWorkbook.SaveCopyAs "c:\pub\source\saturday2.xlsm"
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,326
Messages
6,054,744
Members
444,748
Latest member
knowak87

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