Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Remove Modules not working

Hi

I have the following code which should remove modules have it doesn't seem
to work unless I step through it using F8.

Activesheet.cmdSendEmail.Visible = True
Application.SendKeys ("%te" & "^{TAB}" & "{TAB}{DEL}" & "{TAB}{DEL}" &
"{ENTER}")
Call RemoveModules
Cells.Select
Selection.Locked = True
Range("B6").Select
Call ProtectSheet
ActiveWorkbook.SaveAs "C:\Adv.xls"
MsgBox "CLICK EMAIL BUTTON", vbOKOnly

Any suggestions would be very much appreciated.

Thanks
Noemi
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Remove Modules not working

What is in the procedure RemoveModules?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Noemi" wrote in message
...
Hi

I have the following code which should remove modules have it doesn't seem
to work unless I step through it using F8.

Activesheet.cmdSendEmail.Visible = True
Application.SendKeys ("%te" & "^{TAB}" & "{TAB}{DEL}" & "{TAB}{DEL}" &
"{ENTER}")
Call RemoveModules
Cells.Select
Selection.Locked = True
Range("B6").Select
Call ProtectSheet
ActiveWorkbook.SaveAs "C:\Adv.xls"
MsgBox "CLICK EMAIL BUTTON", vbOKOnly

Any suggestions would be very much appreciated.

Thanks
Noemi



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Remove Modules not working

Here is the procedure

Public Sub RemoveModules()
Dim vbproject As vbproject
Dim VBComp As VBComponent
Dim vbcomp1 As VBComponent
Dim vpcom2 As VBComponent
Dim vpcomp3 As VBComponent
Dim vpcomp4 As VBComponent
Dim vpcomp5 As VBComponent
Set vbproject = ThisWorkbook.vbproject
Set VBComp = ThisWorkbook.vbproject.vbcomponents("Module3")
Set vbcomp1 = ThisWorkbook.vbproject.vbcomponents("Module4")
Set vbcomp2 = ThisWorkbook.vbproject.vbcomponents("Module6")
Set vbcomp3 = ThisWorkbook.vbproject.vbcomponents("Module7")
Set vbcomp4 = ThisWorkbook.vbproject.vbcomponents("Module8")
ThisWorkbook.vbproject.vbcomponents.Remove VBComp
ThisWorkbook.vbproject.vbcomponents.Remove vbcomp1
ThisWorkbook.vbproject.vbcomponents.Remove vbcomp2
ThisWorkbook.vbproject.vbcomponents.Remove vbcomp3
ThisWorkbook.vbproject.vbcomponents.Remove vbcomp4
End Sub

Thanks

"Bob Phillips" wrote:

What is in the procedure RemoveModules?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Noemi" wrote in message
...
Hi

I have the following code which should remove modules have it doesn't seem
to work unless I step through it using F8.

Activesheet.cmdSendEmail.Visible = True
Application.SendKeys ("%te" & "^{TAB}" & "{TAB}{DEL}" & "{TAB}{DEL}" &
"{ENTER}")
Call RemoveModules
Cells.Select
Selection.Locked = True
Range("B6").Select
Call ProtectSheet
ActiveWorkbook.SaveAs "C:\Adv.xls"
MsgBox "CLICK EMAIL BUTTON", vbOKOnly

Any suggestions would be very much appreciated.

Thanks
Noemi




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Remove Modules not working

If that is the exact you are using, addition of "Option Explicit" at the top
of the module would be a good start.
Actually better, ToolsOptionsEditor check "Require Variable Declaration".

Use of a With would make it more readable.
And maybe a loop.

With ThisWorkbook.VBProject.VBComponents
For i = 3 To 8
.Remove .Item("Module" & i)
Next
End With

If using Excel 2002 or higher, make sure you have checked the
ToolsMacroSecurityTrusted Sources"Trust access to Visual Basic Project"

NickHK

"Noemi" wrote in message
...
Here is the procedure

Public Sub RemoveModules()
Dim vbproject As vbproject
Dim VBComp As VBComponent
Dim vbcomp1 As VBComponent
Dim vpcom2 As VBComponent
Dim vpcomp3 As VBComponent
Dim vpcomp4 As VBComponent
Dim vpcomp5 As VBComponent
Set vbproject = ThisWorkbook.vbproject
Set VBComp = ThisWorkbook.vbproject.vbcomponents("Module3")
Set vbcomp1 = ThisWorkbook.vbproject.vbcomponents("Module4")
Set vbcomp2 = ThisWorkbook.vbproject.vbcomponents("Module6")
Set vbcomp3 = ThisWorkbook.vbproject.vbcomponents("Module7")
Set vbcomp4 = ThisWorkbook.vbproject.vbcomponents("Module8")
ThisWorkbook.vbproject.vbcomponents.Remove VBComp
ThisWorkbook.vbproject.vbcomponents.Remove vbcomp1
ThisWorkbook.vbproject.vbcomponents.Remove vbcomp2
ThisWorkbook.vbproject.vbcomponents.Remove vbcomp3
ThisWorkbook.vbproject.vbcomponents.Remove vbcomp4
End Sub

Thanks

"Bob Phillips" wrote:

What is in the procedure RemoveModules?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Noemi" wrote in message
...
Hi

I have the following code which should remove modules have it doesn't

seem
to work unless I step through it using F8.

Activesheet.cmdSendEmail.Visible = True
Application.SendKeys ("%te" & "^{TAB}" & "{TAB}{DEL}" &

"{TAB}{DEL}" &
"{ENTER}")
Call RemoveModules
Cells.Select
Selection.Locked = True
Range("B6").Select
Call ProtectSheet
ActiveWorkbook.SaveAs "C:\Adv.xls"
MsgBox "CLICK EMAIL BUTTON", vbOKOnly

Any suggestions would be very much appreciated.

Thanks
Noemi






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
Public, Private, Event modules, Forms modules,,, Jim May Excel Programming 11 October 31st 05 03:12 AM
Basic question - modules and class modules - what's the difference? Mark Stephens[_3_] Excel Programming 9 May 8th 05 11:48 AM
When to code in sheet or userform modules and when to use modules Tony James Excel Programming 1 December 16th 04 10:02 PM
VBA & XL2K: Working with objects/class modules Mike Mertes Excel Programming 0 November 1st 04 02:55 PM
Remove code from all modules closes Excel Stuart[_5_] Excel Programming 0 June 30th 04 06:22 PM


All times are GMT +1. The time now is 10:26 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"