SOLVED!Read Only Macro ?

ROBINSYN

Board Regular
Joined
Aug 19, 2002
Messages
188
Is there a macro so I can set a file to read only before close?
This message was edited by ROBINSYN on 2002-11-10 21:45
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209
On 2002-10-27 21:03, ROBINSYN wrote:
Is there a macro so I can set a file to read only before close?

While in the VBA Editor press F1
Type in Readonly > you should get what you need from the help...
 

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Sub SetReadOnly()
'Run from Standard Module.
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
'You must add your Drive, Folder and File Name below to run this.
Set f = fs.GetFile(fs.GetFileName("C:MyFilesExcelTestMyReadOnlyMacro.xls"))
f.Attributes = f.Attributes + 1
End Sub
 

Haluk

Rules Violation
Joined
Oct 26, 2002
Messages
1,075
On 2002-10-27 21:03, ROBINSYN wrote:
Is there a macro so I can set a file to read only before close?

Hi !

Here is an alternative way to set the "ReadOnly" property for the file in use;


Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
SetAttr ThisWorkbook.Path & "" & ThisWorkbook.Name, vbReadOnly
End Sub
This message was edited by Raider on 2002-10-28 02:27
 

Watch MrExcel Video

Forum statistics

Threads
1,122,575
Messages
5,596,961
Members
414,114
Latest member
Lost_User21

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
Top