Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel VBA Project Has Protection?

I'm trying to find a way to programmatically check if a workbooks VBA
project has protection.

I know ActiveWorkbook.VBProject.Protection will tell you if it is
currently locked but that doesn't help if the project has already been
unprotected ie by a user (or another bit of code) has unprotected the
project.

So what i am trying to do is if a VBA project doesn't have any
protection, my code will ask the user for a password and then set the
password by using sendkeys. If they already have the VBA project
protected, it will ask them for their password, then unlock the
project using sendkeys. My problem is when a user opens up the
workbook, manually opens the VBA code by entering the VBA password. If
my code is then run ActiveWorkbook.VBProject.Protection will return 0.
If I had a way to know the VBA project was password protected but
currently unlocked, then i would not need to ask the user for a
password.

Any help would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Excel VBA Project Has Protection?

I'd recommend you read this before proceeding.

http://www.cpearson.com/excel/vbe.aspx
--
HTH,

Barb Reinhardt



"Crookie74" wrote:

I'm trying to find a way to programmatically check if a workbooks VBA
project has protection.

I know ActiveWorkbook.VBProject.Protection will tell you if it is
currently locked but that doesn't help if the project has already been
unprotected ie by a user (or another bit of code) has unprotected the
project.

So what i am trying to do is if a VBA project doesn't have any
protection, my code will ask the user for a password and then set the
password by using sendkeys. If they already have the VBA project
protected, it will ask them for their password, then unlock the
project using sendkeys. My problem is when a user opens up the
workbook, manually opens the VBA code by entering the VBA password. If
my code is then run ActiveWorkbook.VBProject.Protection will return 0.
If I had a way to know the VBA project was password protected but
currently unlocked, then i would not need to ask the user for a
password.

Any help would be appreciated.
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Excel VBA Project Has Protection?

You need to find the VBProject one way or another. By workbook name,
you can use Workbooks("BookName").VBProject. For the project that is
presently active in the VBA editor, use
Application.VBE.ActiveVBProject. Or, if you know the project name, you
can use Application.VBE.VBProjects("projectName").

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com




On Mon, 29 Mar 2010 08:52:46 -0700 (PDT), Crookie74
wrote:

I'm trying to find a way to programmatically check if a workbooks VBA
project has protection.

I know ActiveWorkbook.VBProject.Protection will tell you if it is
currently locked but that doesn't help if the project has already been
unprotected ie by a user (or another bit of code) has unprotected the
project.

So what i am trying to do is if a VBA project doesn't have any
protection, my code will ask the user for a password and then set the
password by using sendkeys. If they already have the VBA project
protected, it will ask them for their password, then unlock the
project using sendkeys. My problem is when a user opens up the
workbook, manually opens the VBA code by entering the VBA password. If
my code is then run ActiveWorkbook.VBProject.Protection will return 0.
If I had a way to know the VBA project was password protected but
currently unlocked, then i would not need to ask the user for a
password.

Any help would be appreciated.

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
Better protection for VBA project? Ron[_32_] Excel Programming 37 April 26th 23 07:45 PM
VBE Project Protection Nigel RS[_2_] Excel Programming 1 May 9th 07 01:45 PM
VB Project Protection [email protected] Excel Programming 1 July 11th 05 02:42 PM
Project Protection Don Lloyd Excel Programming 2 February 15th 05 12:45 PM
VB project protection Frank C. Excel Programming 2 January 12th 04 02:29 PM


All times are GMT +1. The time now is 12:16 AM.

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

About Us

"It's about Microsoft Excel"