"Ron de Bruin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Sean
>
> My SendMail add in have this option
> http://www.rondebruin.nl/mail/add-in.htm
>
> Or look here
> http://www.cpearson.com/excel/vbe.htm
>
> Another option is to copy all cells to a new worksheet and send that sheet
>
Decided to give some of the code from the CPearson site you suggested a try.
The following, slightly modified code, ran without error, but failed to
delete any code.
I am trying to delete code from a Sheet module (in another book) - at first
I thought maybe I couldn't deleete from a sheet, so I imported another code
module and tried - didn't delete anything from any modules.
ThisWorkbook is running the code to delete code from another workbook - is
that possible?
Public Sub DeleteAllCodeInModule(ByVal OtherBookName As String, _
ByVal Sheet2DelCodeFrom As Integer)
Dim VBCodeMod As CodeModule
Dim StartLine As Long
Dim HowManyLines As Long
Dim OtherBook As Workbook
Set OtherBook = Workbooks(OtherBookName)
Set VBCodeMod =
OtherBook.VBProject.VBComponents(Sheet2DelCodeFrom).CodeModule
With VBCodeMod
StartLine = 1
HowManyLines = .CountOfLines
.DeleteLines StartLine, HowManyLines
End With
End Sub
Public Sub DeleteAllVBA(ByVal OtherBookName As String)
Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents
Dim OtherBook As Workbook
Set OtherBook = Workbooks(OtherBookName)
Set VBComps = OtherBook.VBProject.VBComponents
For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp
End Sub