Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I understtod the code you wrote to remove the macro from the new sheet but
when the original sheet macro tries to execute this code, I get the following error message: "Programatic access to Visual Basic Project is not trusted" Do anybody knows how can I eliminate this? "Ron de Bruin" wrote: Look out This will remove the code from the original workbook You use ThisWorkbook in the code -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Per Jessen" wrote in message ... Assuming the sheet don't have any code which you want to keep, try this: Sub ExtractHL() ' ' ExtractHL Macro ' Extract and send the HL file to customers Sheets("daily hectolitres").Copy ' Delete event code in copied sheet Dim strName As String strName = ActiveSheet.CodeName With ThisWorkbook.VBProject.VBComponents(strName).CodeM odule .DeleteLines 1, .CountOfLines End With ' Open email and attach file to email ActiveWorkbook.SaveAs Filename:="daily hectolitre.xls" ActiveWorkbook.ChangeFileAccess xlReadOnly Application.Dialogs(xlDialogSendMail).Show "ABI- Daily Hectolitres", "ABI daily hectolitres" ActiveWorkbook.Close False Kill "daily hectolitre.xls" Sheets("daily procedure").Select Range("C3").Select End Sub Regards, Per "LesG" skrev i meddelelsen ... I have code in a workbook that copies a worksheet to send by email... The code works perfectly, but the sheet I am copiyng has code that I want to remove before emailing... The code in the workbook module is as follows: Sub ExtractHL() ' ' ExtractHL Macro ' Extract and send the HL file to customers Sheets("daily hectolitres").Copy ' Open email and attach file to email ActiveWorkbook.SaveAs Filename:="daily hectolitre.xls" ActiveWorkbook.ChangeFileAccess xlReadOnly Application.Dialogs(xlDialogSendMail).Show "ABI- Daily Hectolitres", "ABI daily hectolitres" ActiveWorkbook.Close False Kill "daily hectolitre.xls" Sheets("daily procedure").Select Range("C3").Select End Sub The code that I want to remove from the copied workbook is: Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Me.Range("I4:I34")) Is Nothing Then ActiveCell.Offset(-1, 10).Range("A1").Select End If If Not Intersect(Target, Me.Range("S4:S34")) Is Nothing Then ActiveCell.Offset(0, -10).Range("A1").Select Sheet15.Activate End If End Sub Any suggestions please __________ Information from ESET Smart Security, version of virus signature database 3953 (20090321) __________ The message was checked by ESET Smart Security. http://www.eset.com __________ Information from ESET Smart Security, version of virus signature database 3953 (20090321) __________ The message was checked by ESET Smart Security. http://www.eset.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Programically remove code from a worksheet | Excel Programming | |||
remove vba code before emailing as attachment | Excel Programming | |||
Emailing Worksheet with VBA Code | Excel Programming | |||
Remove VBA code behind a worksheet | Excel Programming | |||
remove code from behind worksheet | Excel Programming |