View Full Version : wipe up MACRO code when WorkBooks Expire
skaswani
10-07-2007, 10:50 AM
Hello
I want to know that is there any way To wipe up Macro Codes automaticlly when excel file expire
Thanks!
Bob Phillips
10-07-2007, 11:35 AM
Wipe up? Expires?
chandansify
10-08-2007, 06:32 PM
Could you please explain, what does Expires mean?
paulked
10-08-2007, 06:41 PM
'Expires' means ended... as in "My Gin has expired, therefore I should retire" or "Why am I the last one wanting a drink... Has my time expired?" etc etc. And my last example... "I'm about to fall asleep, who knows the VBA for 'Go to bed you............................................
yogi_bear_79
10-08-2007, 07:01 PM
Public Sub RemoveAllMacros(objDocument As Object)
Dim i As Long, l As Long
If objDocument Is Nothing Then Exit Sub
i = 0
On Error Resume Next
i = objDocument.VBProject.VBComponents.Count
On Error GoTo 0
If i < 1 Then ' no VBComponents or protected VBProject
MsgBox "The VBProject in " & objDocument.Name & _
" is protected or has no components!", _
vbInformation, "Remove All Macros"
Exit Sub
End If
With objDocument.VBProject
For i = .VBComponents.Count To 1 Step -1
On Error Resume Next
.VBComponents.Remove .VBComponents(i)
' delete the component
On Error GoTo 0
Next i
End With
With objDocument.VBProject
For i = .VBComponents.Count To 1 Step -1
l = 1
On Error Resume Next
l = .VBComponents(i).CodeModule.CountOfLines
.VBComponents(i).CodeModule.DeleteLines 1, l
' clear lines
On Error GoTo 0
Next i
End With
End Sub
Aussiebear
10-09-2007, 02:14 AM
Hello
I want to know that is there any way To wipe up Macro Codes automaticlly when excel file expire
When i read this for the first time I thought the OP wanted to;
" Remove macro codes when the file ceases to exist" which brings to mind why do they need this sort of code?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.