![]() |
Delete a module
I am tring to delete a module from excel using VBA. I have figured out how to
do this within the body of the Macro, but my problem comes in when I want to link this to a macro that also saves the file to a directory on my computor and also sends the workbook out as an attachment to a list of users. This is what I got so far: Sub Sendout() 'Saveas Dim VBComp As Object Dim FName As Variant FName = Application.GetSaveAsFilename( _ filefilter:="Excel files (*.xls),*.xls") If FName = False Then ' user clicked cancel Else ThisWorkbook.Saveas Filename:=FName End If 'Rank Range("A3:S32").Select Selection.Sort Key1:=Range("A3"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Range("A1").Select ActiveWorkbook.Save 'Mailworkbook Dim MyArr As Variant MyArr = Sheets("Championship").Range("EmailNames") ActiveWorkbook.SendMail MyArr, "Curtour Results" Set VBComp = ThisWorkbook.VBProject.vbcomponents("Module1") ThisWorkbook.VBProject.vbcomponents.Remove VBComp ActiveWorkbook.Save 'DeleteMOD Dim MyArr As Variant MyArr = Sheets("Championship").Range("EmailNames") ActiveWorkbook.SendMail MyArr, "Curtour Results" End Sub Any suggestions? -- Pete |
All times are GMT +1. The time now is 05:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com