Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
After reading a number of threads on this website, I have managed to define a
password for the VBProject in Workbook, WB, by making use of the following code. However, I would also like to automatically set the option 'Lock project for viewing' to True by code. Can anyone help, what do I need to do? Public Sub ProtectCodeModule(ByVal WB As Workbook, Password as string) Dim VBP As VBProject, oWin As VBIDE.Window Dim wbActive As Workbook Dim i As Integer Set VBP = WB.VBProject Set wbActive = WB If VBP.Protection < vbext_pp_none Then Exit Sub Application.ScreenUpdating = False ' Close any code windows to ensure we hit the right project For Each oWin In VBP.VBE.Windows If InStr(oWin.Caption, "(") 0 Then oWin.Close Next oWin WB.Activate ' Now use SendKeys to write password Application.OnKey "%{F11}" SendKeys "%{F11}%TE" & Password & "~~%{F11}", True End Sub Thanks in anticipation. -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200610/1 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 - Lock for viewing | Excel Discussion (Misc queries) | |||
Excel crashes when adding code using vbproject object? | Excel Programming | |||
Lock Project for Viewing..HELP ME | Excel Programming | |||
Unlock/Lock VBProject through code? | Excel Programming | |||
Unlock/Lock VBProject through code? | Excel Programming |