Test for VBAProject Locked from Viewing

  • Thread starter Thread starter DennisE
  • Start date Start date
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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top