Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm still having some trouble with the code below. It previously worked in
XL2002 and earlier. However, there were some issues on some installations of XL2003 and now consistant errors on XL2007. The error occurs on line, "Set CodeMod = ThisWorkbook.VBProject.VBComponents("ThisWorkbook" ).CodeModule" If I attempt to step through the code, it just gives you an error stating, "Run-time error '1004': Application-defined or object-defined error" If I initiate this code from the button-click as intended, then I get the "Run-time error '1004': Programmatic access to Visual Basic Project is not trusted" Is there a way to achieve what I want in XL2007? Thanks, Paul Private Sub CommandButton1_Click() Dim CodeMod As VBIDE.CodeModule Dim StartLine As Long Dim ProcLen As Long Set CodeMod = ThisWorkbook.VBProject.VBComponents("ThisWorkbook" ).CodeModule With CodeMod StartLine = .ProcStartLine("Workbook_Open", vbext_pk_Proc) ProcLen = .ProcCountLines("Workbook_Open", vbext_pk_Proc) .DeleteLines StartLine, ProcLen End With End Sub -- |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Removing Macro in ThisWorkbook | Excel Programming | |||
Programmatically removing data filters | Excel Programming | |||
Removing Add-ins programmatically from Excel 2003 using VBScript | Excel Programming | |||
Remove ThisWorkbook code via VBA | Excel Programming | |||
Removing Checkboxes Programmatically | Excel Programming |