Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Module still there even after remove and save

I'm running some code in a module and then removing the module using
ThisWorkBook.VBProject.VBComponents.Remove etc. I then save the file
using ThisWorkBook.Save. However, if I dont save the file on closing
when prompted by excel then when I reopen the file the module is still
there!! What am I doing wrong?? (The module is removed if I save at the
excel prompt.)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Module still there even after remove and save

This worked for me

' in Module2
Sub test()
Dim oComp As Object
Set oComp = ThisWorkbook.VBProject.VBComponents("Module2")
ThisWorkbook.VBProject.VBComponents.Remove oComp
[a1] = ThisWorkbook.VBProject.VBComponents.Count ' 6
ThisWorkbook.Save
Application.OnTime Now, "saveme"
End Sub


'in Module1
Sub saveme()
[a2] = ThisWorkbook.VBProject.VBComponents.Count ' 5
ThisWorkbook.Save
End Sub

The point being the module is only removed after all code in it terminates

Regards,
Peter T


"shurstgbr" wrote in message
oups.com...
I'm running some code in a module and then removing the module using
ThisWorkBook.VBProject.VBComponents.Remove etc. I then save the file
using ThisWorkBook.Save. However, if I dont save the file on closing
when prompted by excel then when I reopen the file the module is still
there!! What am I doing wrong?? (The module is removed if I save at the
excel prompt.)



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
Remove Module not working Noemi Excel Programming 1 October 19th 06 10:09 AM
Remove the module dayanand108[_5_] Excel Programming 2 September 26th 05 09:11 AM
Remove and Import Module Richard Excel Programming 1 September 2nd 05 09:18 AM
Remove VBA Project module TMR Excel Programming 0 December 11th 03 07:04 PM
Remove VB Module from workbook Nikos Yannacopoulos[_2_] Excel Programming 2 October 3rd 03 02:11 PM


All times are GMT +1. The time now is 08:07 AM.

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

About Us

"It's about Microsoft Excel"