Programmatically unlock Project

rex759

Well-known Member
Joined
Nov 8, 2004
Messages
610
Office Version
  1. 365
Platform
  1. Windows
Hello,

I’m using the code below to copy a module to a new workbook. The only issue I’m having is I want to lock the project from viewing. If the project is locked, the module doesn’t get copied over. Is there a way to unlock the project, run the macro and relock it?

Code:
'Copy the "HIDE" macro to new workbook
Const MODULE_NAME    As String = "hide"         ' Name of the module to transfer
Const TEMPFILE2       As String = "c:\Modul.bas" ' temp textfile
  
   '** export the module to a textfile
  Workbooks(mydatafile).VBProject.VBComponents(MODULE_NAME).Export TEMPFILE2
   'import the module to the new workbook
  Workbooks(TEMPFILE).VBProject.VBComponents.Import TEMPFILE2
   'kill the textfile
   Kill TEMPFILE2
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi,

The point of the Project Protection is to protect the project, I don't believe you can do this with code. Would have to be a manual step i'm afraid.
 
Upvote 0
Is this not against board rules anyhow to post replies that breach protection?

It is against board rules to ask questions and post replies on cracking and/or bypassing passwords and protection. My understanding is that the OP is trying to make his own workbook actually more secure by locking/unlocking the VBAProject programmatically.

Also, the link I provided requires that the user know the password anyway. ;)
 
Upvote 0
You are correct MrKowz. It's my code and workbook. It's going to be used by others and I wnated to protect the project from being tampared with.

Thank you
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,519
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top