Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete/Hide Macro after executing

Status
Not open for further replies.

roelmcebu

Technical User
Feb 14, 2004
27
PH
How do I delete or hide a macro from users after it executes?

This macro just extracts data from several text files and pastes(formatted) it in the worksheets.

 
To hide the macro, simply go to the VB Editor and right click on the VBA Project title. Select VBA Project Properties and go to the Protection tab. You can add a password there.

To delete the module, you can use:
Code:
On Error Resume Next
  ActiveWorkbook.VBProject.VBComponents.Remove ActiveWorkbook.VBProject.VBComponents("Module1")

[tt]_____
[blue]-John[/blue]
[/tt][red]Quidquid latine dictum sit, altum viditur[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
hi anotherhiggins,

the code gave me an argument not optional error, pointing to .Remove
 
Is the workbook containing the macro active when the code is run? Did you include the
[blue]On Error Resume Next[/blue]
line?

But stepping back, how is code going to be used/distributed? I'd suggest password protecting it rather than completely deleting the module.

[tt]_____
[blue]-John[/blue]
[/tt][red]Quidquid latine dictum sit, altum viditur[/red]

Help us help you. Please read FAQ181-2886 before posting.
 
If your goal is to run a macro to edit/generate data, and you don't want others to see the code, then consider making your code an .xla file.

This way the code is available to you, but is not attached to the file/data being generated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top