By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,886 Members | 1,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,886 IT Pros & Developers. It's quick & easy.

Excel macro and 2003

P: n/a

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

Additional information: De gebeurtenisafhandeling is ongeldig(the eventproc
isn't correct)

Can someone help me

Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.