M
Matt
I am trying to use the code:
Sub delete_all_code (module_name)
Dim VBCodeMod as VBComponent
Dim StartLine As Long
Dim HowManyLines As Long
Set VBCodeMod =
ThisWorkbook.VBProject.VBComponents(module_name)CodeModule
With VBCodeMod
StartLine = 1
HowManyLines = .CountOfLines
.DeleteLines StartLine, HowManyLines
End With
End Sub
(taken from G.Groups many years ago)
that has worked for me with no problems in the past. I think I was
using excel 2000 when I first used this.
I am now using excel 2003, and i have the VBA Extensibility reference
'activated' . Have also tried unchecking this and using 'Dim VBCodeMod
as Object' with no success.
When I try to run this I get the following error:
Run-time error '1004':
Method 'VBProject' of Object '_Workbook' failed
Any ideas as to how I can get this to work or any other way of deleting
either:
1 - all the code in an excel VBA module
or
2 - the entire VBA module (preferable)
for a given module.
Many thanks in advance for any help!
Matt
Sub delete_all_code (module_name)
Dim VBCodeMod as VBComponent
Dim StartLine As Long
Dim HowManyLines As Long
Set VBCodeMod =
ThisWorkbook.VBProject.VBComponents(module_name)CodeModule
With VBCodeMod
StartLine = 1
HowManyLines = .CountOfLines
.DeleteLines StartLine, HowManyLines
End With
End Sub
(taken from G.Groups many years ago)
that has worked for me with no problems in the past. I think I was
using excel 2000 when I first used this.
I am now using excel 2003, and i have the VBA Extensibility reference
'activated' . Have also tried unchecking this and using 'Dim VBCodeMod
as Object' with no success.
When I try to run this I get the following error:
Run-time error '1004':
Method 'VBProject' of Object '_Workbook' failed
Any ideas as to how I can get this to work or any other way of deleting
either:
1 - all the code in an excel VBA module
or
2 - the entire VBA module (preferable)
for a given module.
Many thanks in advance for any help!
Matt