stanl
06-28-2007, 06:03 AM
I am, and will be creating workbooks with large amounts of data placed in pivot tables or holding survey results... really lots of stuff.
These need to be made available on a network folder with the normal caveats of users not making changes or using save_as. Rather than going the route of readonly attributes, sheet passwords I Googled code for Workbook_Open and Before close events which (1) disable menus and toolbars (2) close the workbook without saving changes (3) disable Alt_F8 and set password for Alt_f11 [which also re-enables everything, so I can update]. What I want to do is write a procedure to apply this schema to any given workbook. Roughly...
Sub protect_wkb()
Dim WB As Workbook
f = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls), *.xls", _
Title:="Please Select Import File")
If f = False Then Exit Sub
Application.Workbooks.Open Filename:=f
Set WB = ActiveWorkbook
'this is where I need help:
'this code, originally posted by Ivan sets the VBProject Password
'so users cannot view code.
Call Change_VBA_PW(WB)
WB.Close True
End Sub
In the
'this is where I need help: section, I need to insert the contents of the 2 attached text files into the workbook code, a standard module. The workbooks I will apply this schema to may or may not have macro code, but none will have exisiting workbook event code.
Admittedly, this is a hack and not refined, but if I can get help inserting the text files, refinements will follow.
Stan
Edited 29-Jun-07 by geekgirlau. Reason: insert line breaks
These need to be made available on a network folder with the normal caveats of users not making changes or using save_as. Rather than going the route of readonly attributes, sheet passwords I Googled code for Workbook_Open and Before close events which (1) disable menus and toolbars (2) close the workbook without saving changes (3) disable Alt_F8 and set password for Alt_f11 [which also re-enables everything, so I can update]. What I want to do is write a procedure to apply this schema to any given workbook. Roughly...
Sub protect_wkb()
Dim WB As Workbook
f = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls), *.xls", _
Title:="Please Select Import File")
If f = False Then Exit Sub
Application.Workbooks.Open Filename:=f
Set WB = ActiveWorkbook
'this is where I need help:
'this code, originally posted by Ivan sets the VBProject Password
'so users cannot view code.
Call Change_VBA_PW(WB)
WB.Close True
End Sub
In the
'this is where I need help: section, I need to insert the contents of the 2 attached text files into the workbook code, a standard module. The workbooks I will apply this schema to may or may not have macro code, but none will have exisiting workbook event code.
Admittedly, this is a hack and not refined, but if I can get help inserting the text files, refinements will follow.
Stan
Edited 29-Jun-07 by geekgirlau. Reason: insert line breaks