Hello,
I am wondering how I can write a macro to set file attributes to hidden/read only, when I close it. Any tips are welcome. Thank you in advance.
Hello,
I am wondering how I can write a macro to set file attributes to hidden/read only, when I close it. Any tips are welcome. Thank you in advance.
Last edited by Karolis; 09-21-2010 at 03:23 AM.
After closing:
![]()
CreateObject("scripting.filesystemobject").getfile("E:\file.xls").attributes = 3
Last edited by snb; 09-20-2010 at 09:44 AM.
sorry, i'm not very great with excel. where do i have to put this in vba? in workbook general?
Put this code in the 'ThisWorkbook module in teh VBEditor (alt-F11)
The file will be Hidden & Readonly.
![]()
Private Sub Workbook_BeforeClose(Cancel As Boolean) If ThisWorkbook.Saved Then CreateObject("scripting.filesystemobject").getfile(ThisWorkbook.FullName).Attributes = 3 End Sub
ThanxI was about to post that I figured it out already. Just one more question:
attributes = 1 file is read only
attributes = 2 file is hidden
attributes = 3 file is read only and hidden.
Am I correct? and is there more options?
You are correct, more options you'll find in the VBEditor's help, look for 'attributes'.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks