try this
Sub sMakeMacroCode _
(ByVal wbBoek As Excel.Workbook, ByVal wsSheet As Excel.Worksheet, ByVal
sObject As String, ByVal sAction As String, ByVal sCode As String)
'Ex:sMakeMacroCode(objWB, "Blad1", "Worksheet", "Activate", Chr(9) &
"ActiveSheet.EnableAutoFilter = True")
Dim StartLine As Long, X As Byte
'wbBoek.Application.Visible = True
Try
With wbBoek.VBProject.VBComponents.Item(wsSheet.Index + 1).CodeModule
StartLine = .CreateEventProc(sAction, sObject) + 1
..InsertLines(StartLine, sCode)
X = wbBoek.VBProject.Protection
wbBoek.Application.VBE.MainWindow.Visible = False
'Close is beter than visible but won't work
End With
Catch ex As Exception
MsgBox("Fout: " & ex.Message)
End Try
End Sub 'sMakeMacroCode
its add some code to an workbook on the level worksheet
in excell 2002 or higher you need to allow editing the VBE
google on VBProject.VBComponents will find mmore info
Jan
"Paul Clement" <Us***********************@swspectrum.com> schreef in bericht
news:g0********************************@4ax.com...
On Tue, 13 Sep 2005 13:12:47 +0200, "Lars Netzel" <ui****@adf.se> wrote:
¤ Can you alter them or remove them?
¤
¤ /Lars
Since this involves automation, you might post this question in
microsoft.public.excel.programming.
I'm afraid I don't know of a way to modify the code modules
programmatically.
Paul
~~~~
Microsoft MVP (Visual Basic)