Hi,
I NEED a macro into a ,by code, generated excel file
I call the sub with the 1 line: the sub follows
-----------start code---------------------------
sMakeMacroCode(objWB, "Blad1", "Worksheet", "Activate", Chr(9) &
"ActiveSheet.EnableAutoFilter = True")
Sub sMakeMacroCode _
(ByVal wbBoek As Excel.Workbook, ByVal sModuleName As String, 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
With wbBoek.VBProject.VBComponents.Item(sModuleName).Co deModule
'the next line wont work
StartLine = .CreateEventProc(sAction, sModuleName) + 1
'For X = 1 To 100 : Next
..InsertLines(StartLine, sCode)
End With
End Sub
-----------end code---------------------------
I get the error
An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in system.windows.forms.dll
Additional information: De gebeurtenisafhandeling is ongeldig(the eventproc
isn't correct)
Can someone help me