View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default security for folder??

Hi jer,

jer wrote:
Thanks Jake. We are using windows based security however supervisors
are requesting greater security for the files in particular folders.
One thing though, I notice that when the password is assigned
unprotecting the workbook is not possible. Can somebody manually
unprotect the workbook when the password is assigned via code


It works for me. When I run the routine below, I can then open all
workbooks in the C:\test folder using the password "test". So whatever you
passed in the Password argument should work when opening them manually.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


Private Const msFOLDER_PATH As String = "C:\test"

Sub demo()
Dim fso As Object
Dim fil As Object

Set fso = CreateObject("Scripting.FileSystemObject")

For Each fil In fso.GetFolder(msFOLDER_PATH).Files
If fil.Type = "Microsoft Excel Worksheet" Then
With Workbooks.Open(fil.Path, False)
Application.DisplayAlerts = False
.SaveAs Filename:=.FullName, Password:="test"
Application.DisplayAlerts = True
.Close False
End With
End If
Next fil

Set fso = Nothing
End Sub