Test for VBAProject Locked from Viewing

D

DennisE

Is it possible to test from within my Excel program
as to whether the overall VBAProject is Locked from Viewing?
(I would like to branch one way within the program for knowledgable,
trustworthy users who have the unlocked version, but another way
for regular users for whom the code is locked from viewing.)

-- Dennis Eisen
 
C

Chip Pearson

Dennis,

Try something like the following:

If ThisWorkbook.VBProject.Protection = 0 Then
Debug.Print "Not locked"
Else
Debug.Print "Locked"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
D

DennisE

Chip,
Thanks so much for your help; my
final version took the form

If ThisWorkbook.VBProject.Protection _
= vbext_pp_locked Then
[do this code for simpletons]
Else
[do this code for the cognesenti]
End If

(This requires early binding with vbe6ext.olb, but my program required it
anyway.)

-- Dennis Eisen
 
Top