ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to make VBA code to self-destroy itself? (https://www.excelbanter.com/excel-programming/316280-how-make-vba-code-self-destroy-itself.html)

count

How to make VBA code to self-destroy itself?
 
Hi,
I need to ensure that users keep updating software in VBA. So I need to warn
them, say 1 month in advance and past that, I need to disable their access
to crucial module.
I thought of removing that module. How do I do that programmatically?
TIA
Paul



Frank Kabel

How to make VBA code to self-destroy itself?
 
Hi Paul
I wouldn't recommend this.
First: Easy to circumvent by an experienced user by disabling this code part
Second: Not sure if you're allowed to do 'deleting' code and the possible
legal consequences.

Bottom line: In Excel there's no real way to protect/secure your code

"count" wrote:

Hi,
I need to ensure that users keep updating software in VBA. So I need to warn
them, say 1 month in advance and past that, I need to disable their access
to crucial module.
I thought of removing that module. How do I do that programmatically?
TIA
Paul




count

How to make VBA code to self-destroy itself?
 
Thanks Frank,
I still need the answer though.
The app and code are mine and users agree that it's better for them to have
dead application rather than one that lies about tax rebate rates - stuff is
serious!
They can disable that code, you say - that's why I prefer app to castrate
itself. They can still use backup and reimport missing module but in this
case my butt is safe.
So question is still open
Paul

Użytkownik "Frank Kabel" napisał w wiadomości
...
Hi Paul
I wouldn't recommend this.
First: Easy to circumvent by an experienced user by disabling this code
part
Second: Not sure if you're allowed to do 'deleting' code and the possible
legal consequences.

Bottom line: In Excel there's no real way to protect/secure your code

"count" wrote:

Hi,
I need to ensure that users keep updating software in VBA. So I need to
warn
them, say 1 month in advance and past that, I need to disable their
access
to crucial module.
I thought of removing that module. How do I do that programmatically?
TIA
Paul






Bob Phillips[_6_]

How to make VBA code to self-destroy itself?
 
If you must do it, you could hide the sheet, but in VBA you can hid to a
state of xlVeryHidden, which stops them un hiding in Excel itself as it
doesn't even show in the list of hidden worksheets.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"count" wrote in message
...
Thanks Frank,
I still need the answer though.
The app and code are mine and users agree that it's better for them to

have
dead application rather than one that lies about tax rebate rates - stuff

is
serious!
They can disable that code, you say - that's why I prefer app to castrate
itself. They can still use backup and reimport missing module but in this
case my butt is safe.
So question is still open
Paul

Użytkownik "Frank Kabel" napisał w wiadomości
...
Hi Paul
I wouldn't recommend this.
First: Easy to circumvent by an experienced user by disabling this code
part
Second: Not sure if you're allowed to do 'deleting' code and the

possible
legal consequences.

Bottom line: In Excel there's no real way to protect/secure your code

"count" wrote:

Hi,
I need to ensure that users keep updating software in VBA. So I need to
warn
them, say 1 month in advance and past that, I need to disable their
access
to crucial module.
I thought of removing that module. How do I do that programmatically?
TIA
Paul








Tom Ogilvy

How to make VBA code to self-destroy itself?
 
http://groups.google.com/groups?thre...%40tkmsftngp07


''Needs a reference to the VB Extensibility library set
'Removes from active workbook all:
''Regular modules
''Class modules
''Userforms
''Code in sheet and workbook modules
''Non built-in references
''Excel 4 macro sheets
''Dialog sheets
Sub RemoveAllCode()
Dim VBComp As Object, AllComp As Object, ThisProj As Object
Dim ThisRef As Reference, WS As Worksheet, DLG As DialogSheet
Set ThisProj = ActiveWorkbook.VBProject
Set AllComp = ThisProj.VBComponents
For Each VBComp In AllComp
With VBComp
Select Case .Type
Case vbext_ct_StdModule, vbext_ct_ClassModule, _
vbext_ct_MSForm
AllComp.Remove VBComp
Case vbext_ct_Document
.CodeModule.DeleteLines 1, .CodeModule.CountOfLines
End Select
End With
Next
For Each ThisRef In ThisProj.References
If Not ThisRef.BuiltIn Then ThisProj.References.Remove ThisRef
Next
Application.DisplayAlerts = False
For Each WS In Excel4MacroSheets
WS.Delete
Next
For Each DLG In DialogSheets
DLG.Delete
Next
End Sub

above previously posted by Jim Rech.

--
Regards,
Tom Ogilvy

"count" wrote in message
...
Thanks Frank,
I still need the answer though.
The app and code are mine and users agree that it's better for them to

have
dead application rather than one that lies about tax rebate rates - stuff

is
serious!
They can disable that code, you say - that's why I prefer app to castrate
itself. They can still use backup and reimport missing module but in this
case my butt is safe.
So question is still open
Paul

Użytkownik "Frank Kabel" napisał w wiadomości
...
Hi Paul
I wouldn't recommend this.
First: Easy to circumvent by an experienced user by disabling this code
part
Second: Not sure if you're allowed to do 'deleting' code and the

possible
legal consequences.

Bottom line: In Excel there's no real way to protect/secure your code

"count" wrote:

Hi,
I need to ensure that users keep updating software in VBA. So I need to
warn
them, say 1 month in advance and past that, I need to disable their
access
to crucial module.
I thought of removing that module. How do I do that programmatically?
TIA
Paul








count

How to make VBA code to self-destroy itself?
 
Tom,
Thanks, Danke, Merci!
wwwbwy?! (where will we be without you?)
Paul

Użytkownik "Tom Ogilvy" napisał w wiadomości
...
http://groups.google.com/groups?thre...%40tkmsftngp07


''Needs a reference to the VB Extensibility library set
'Removes from active workbook all:
''Regular modules
''Class modules
''Userforms
''Code in sheet and workbook modules
''Non built-in references
''Excel 4 macro sheets
''Dialog sheets
Sub RemoveAllCode()
Dim VBComp As Object, AllComp As Object, ThisProj As Object
Dim ThisRef As Reference, WS As Worksheet, DLG As DialogSheet
Set ThisProj = ActiveWorkbook.VBProject
Set AllComp = ThisProj.VBComponents
For Each VBComp In AllComp
With VBComp
Select Case .Type
Case vbext_ct_StdModule, vbext_ct_ClassModule, _
vbext_ct_MSForm
AllComp.Remove VBComp
Case vbext_ct_Document
.CodeModule.DeleteLines 1, .CodeModule.CountOfLines
End Select
End With
Next
For Each ThisRef In ThisProj.References
If Not ThisRef.BuiltIn Then ThisProj.References.Remove ThisRef
Next
Application.DisplayAlerts = False
For Each WS In Excel4MacroSheets
WS.Delete
Next
For Each DLG In DialogSheets
DLG.Delete
Next
End Sub

above previously posted by Jim Rech.

--
Regards,
Tom Ogilvy

"count" wrote in message
...
Thanks Frank,
I still need the answer though.
The app and code are mine and users agree that it's better for them to

have
dead application rather than one that lies about tax rebate rates - stuff

is
serious!
They can disable that code, you say - that's why I prefer app to castrate
itself. They can still use backup and reimport missing module but in this
case my butt is safe.
So question is still open
Paul

Użytkownik "Frank Kabel" napisał w wiadomości
...
Hi Paul
I wouldn't recommend this.
First: Easy to circumvent by an experienced user by disabling this code
part
Second: Not sure if you're allowed to do 'deleting' code and the

possible
legal consequences.

Bottom line: In Excel there's no real way to protect/secure your code

"count" wrote:

Hi,
I need to ensure that users keep updating software in VBA. So I need
to
warn
them, say 1 month in advance and past that, I need to disable their
access
to crucial module.
I thought of removing that module. How do I do that programmatically?
TIA
Paul










Ant[_6_]

How to make VBA code to self-destroy itself?
 
"count" wrote in message ...
Hi,
I need to ensure that users keep updating software in VBA. So I need to warn
them, say 1 month in advance and past that, I need to disable their access
to crucial module.
I thought of removing that module. How do I do that programmatically?
TIA
Paul


Rather than bothering to unload the xla I would just make sure that
all the functions generate an error, or return #Value, if it is out of
date.

To return #Value use the following:

Public Function FunctionErrVal() As Variant
FunctionErrVal = CVErr(2015)
End Function


All times are GMT +1. The time now is 09:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com