Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default No success deleting modules

I have three modules in a worksheet. I'm calling a Sub in Module3 which
needs to delete Module1 and Module2 then save the wookbook. The only
time it works is if I run it standalone. If it's called, the modules
aren't removed. I considered deleting all vbComponents but I need
Module3 left intact to transfer control to a new workbook. Maybe I need
to somehow transfer control to a Sub in Module3 rather than call it.
Thoughts?

The called Sub in Module3 is coded as follows:

Sub DelModules()
Dim VBComp1 As VBComponent
Dim VBComp2 As VBComponent
Set VBComp1 = ThisWorkbook.VBProject.VBComponents("Module1")
Set VBComp2 = ThisWorkbook.VBProject.VBComponents("Module2")
ThisWorkbook.VBProject.VBComponents.Remove VBComp1
ThisWorkbook.VBProject.VBComponents.Remove VBComp2
End Sub

--
BrianG

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default No success deleting modules

If you try to save the workbook before the code thread that deletes the
modules completes, then it will be saved with the modules intact. You might
try using application.Ontime to break this thread. Do the save in the code
that the ontime executes.

--
Regards,
Tom Ogilvy

BrianG wrote in message
...
I have three modules in a worksheet. I'm calling a Sub in Module3 which
needs to delete Module1 and Module2 then save the wookbook. The only
time it works is if I run it standalone. If it's called, the modules
aren't removed. I considered deleting all vbComponents but I need
Module3 left intact to transfer control to a new workbook. Maybe I need
to somehow transfer control to a Sub in Module3 rather than call it.
Thoughts?

The called Sub in Module3 is coded as follows:

Sub DelModules()
Dim VBComp1 As VBComponent
Dim VBComp2 As VBComponent
Set VBComp1 = ThisWorkbook.VBProject.VBComponents("Module1")
Set VBComp2 = ThisWorkbook.VBProject.VBComponents("Module2")
ThisWorkbook.VBProject.VBComponents.Remove VBComp1
ThisWorkbook.VBProject.VBComponents.Remove VBComp2
End Sub

--
BrianG

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply
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
Formula for success... corny I know Roger Excel Worksheet Functions 4 February 28th 09 02:53 AM
Determining football success.. Always Learning Excel Discussion (Misc queries) 0 June 16th 05 09:00 AM
Deleting blank modules bj Excel Discussion (Misc queries) 0 June 2nd 05 07:52 PM
No Success with GetSaveAs D.Parker Excel Discussion (Misc queries) 5 April 20th 05 02:16 PM
Class Modules vs Modules Jeff Marshall Excel Programming 2 September 28th 03 07:57 PM


All times are GMT +1. The time now is 03:42 AM.

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"