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?
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