LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Paige
 
Posts: n/a
Default Deleting Workbook_Open code


I have set up many files using the Workbook_Open code when a file is
opened. I, in turn, need to delete the code after the file has
processed. I was able to do this, but now my computer won't accept.
The version of Microsoft I am having trouble with is "Microsoft Office
Basic Edition 2003" and the code is as follows:

'deletes workbook open code
Dim DeleteWBOpen As Object
Dim StartLine As Long
Dim HowManyLines As Long

Set DeleteWBOpen =
ThisWorkbook.VBProject.VBComponents("ThisWorkbook" ).CodeModule
With DeleteWBOpen
StartLine = 1
HowManyLines = .CountOfLines
.DeleteLines StartLine, HowManyLines
End With

I have also tried the following and it still gets hung up.

Sub DeleteAllVBA()

Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents

Set VBComps = ActiveWorkbook.VBProject.VBComponents

For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp

End Sub

I have checked the "Microsoft Visual Basics for Applications
Extensibility" box.

Any help??

Thank you


--
Paige
------------------------------------------------------------------------
Paige's Profile: http://www.excelforum.com/member.php...o&userid=23096
View this thread: http://www.excelforum.com/showthread...hreadid=505912

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
programming VBE - Deleting All Code From A Module pm Excel Discussion (Misc queries) 4 December 31st 05 01:21 AM
Change case...help please Terry Excel Worksheet Functions 14 October 2nd 05 12:29 PM
Macro for changing text to Proper Case JPriest Excel Worksheet Functions 3 August 8th 05 09:31 PM
Excel hard code those #'s without deleting the formula or typing# JudiS Excel Discussion (Misc queries) 1 August 1st 05 11:21 PM
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM


All times are GMT +1. The time now is 05:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"