ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set Folder permission by macro (https://www.excelbanter.com/excel-programming/277546-re-set-folder-permission-macro.html)

Jake Marx[_2_]

Set Folder permission by macro
 
Hi Jon-jon,

This isn't easy to do through code. One way is to find a third-party
component that allows you to do it more easily. Another is to do it
yourself with the ADsSecurity.DLL component from MS:

http://support.microsoft.com/default...b;en-us;279682

But the best way IMO, if you can do it, is to set the necessary permissions
on a container folder, then any folder you create under that should inherit
the same security settings.

--
Regards,

Jake Marx
MS MVP - Excel

JON-JON wrote:
Dear Expert,

I created a macro that will create a folder that will be the
container for our monthly report. Is it possible to set the folders
permission using macro. I am using Office XP, OS XP and I am member
of a domain (user-level access).

TIA

Jon-jon

Sub PL01_SetupFolder()
RepDate = LastMonEnd()
MkDir "C:\Report\" & Format(RepDate, "mmm yy")
MkDir "C:\Report\" & Format(RepDate, "mmm yy") & "\DIVISION 1 " &
Format(RepDate, "mmm yy")
MkDir "C:\Report\" & Format(RepDate, "mmm yy") & "\DIVISION 2 " &
Format(RepDate, "mmm yy")
End Sub

Function LastMonEnd() As Date
Dim MonthNum As Integer
RepMonNum = Month(Now()) - 1
Select Case RepMonNum
Case 2
LastMonEnd = DateSerial(Year(Now()), Month(Now()) - 1, 28)
Case 4, 6, 9, 11
LastMonEnd = DateSerial(Year(Now()), Month(Now()) - 1, 30)
Case 0
LastMonEnd = DateSerial(Year(Now()) - 1, 12, 31)
Case Else
LastMonEnd = DateSerial(Year(Now()), Month(Now()) - 1, 31)
End Select
End Function




All times are GMT +1. The time now is 03:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com