Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jer jer is offline
external usenet poster
 
Posts: 25
Default security for folder??

I have searched help in excel and have not seen references to this. Is it
possible to set a password for a folder and not the individuals workbooks in
that folder in excel. Failing that, would it be possible to assign a
password via code to multiple workbooks in a folder
--
thanks as always for the help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default security for folder??

Hi jer,

jer wrote:
I have searched help in excel and have not seen references to this.
Is it possible to set a password for a folder and not the individuals
workbooks in that folder in excel. Failing that, would it be
possible to assign a password via code to multiple workbooks in a
folder


The best way to do this, assuming you're in a networked environment, is to
use Windows-based security on the folder. That will protect the workbooks
better than any form of Excel protection. If you're not sure how to do that
(or don't have the necessary rights), check with your sys admin.

Here's an example that will protect all workbooks within the folder C:\test
with the password "test":

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

--
Regards,

Jake Marx
www.longhead.com


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


  #3   Report Post  
Posted to microsoft.public.excel.programming
jer jer is offline
external usenet poster
 
Posts: 25
Default security for folder??

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
--
thanks as always for the help
jer


"Jake Marx" wrote:

Hi jer,

jer wrote:
I have searched help in excel and have not seen references to this.
Is it possible to set a password for a folder and not the individuals
workbooks in that folder in excel. Failing that, would it be
possible to assign a password via code to multiple workbooks in a
folder


The best way to do this, assuming you're in a networked environment, is to
use Windows-based security on the folder. That will protect the workbooks
better than any form of Excel protection. If you're not sure how to do that
(or don't have the necessary rights), check with your sys admin.

Here's an example that will protect all workbooks within the folder C:\test
with the password "test":

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

--
Regards,

Jake Marx
www.longhead.com


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



  #4   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pulling pdf files from general folder to specific folder [email protected] Excel Discussion (Misc queries) 2 September 8th 09 09:41 PM
how can i change my default working folder to a networked folder? wizard1154 Excel Discussion (Misc queries) 4 April 18th 07 07:29 PM
How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? Subteam Excel Discussion (Misc queries) 2 May 7th 06 08:14 PM
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM


All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"