Remove Module not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have code which includes removing modules however the modules are not
removed only if the program terminates.

Is there a code which can make the program think it has terminated or push
through the remove modules so it preforms the removing of the modules task
and then continuing with the emailing of the form.

I need the form to be emailed without the modules included and I would
prefer not to have user interface a second time after the Modules have been
removed.

Any help would be appreciated.

Thanks
Noemi
 
Remove code should work okay. What does your code look like?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Hi Bob
Below are the codes are am using.
The first is were I prepare to and then email the form. Included at the
beginnig of the code is a call procedure to run through the Remove Modules
code which I have add below the email code.

What I beleive is happening is, the modules do not get removed becuase the
procedure has not ended, that is way I need to know if there is a way to make
the system push through the removeal of the modules.

I know that I can use 2 buttons (as the following code is attached to 1 at
this time) which means I would need to have the first button to remove the
modules and the other second button to email which I was hoping to aviod as
this means the users have to click on 2 buttons instead of one.

I hope this makes sense.

Public Sub EmailAction()

Call RemoveModules
If dbAdmin = 1 Then
On Error GoTo SaveError
ActiveWorkbook.SaveAs _
"G:\Merch Services\Advertising" & stBrand
Else
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "C:\ADV.xls" 'save with common name
End If
On Error GoTo Error_MayCauseAnError
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
'emial form
With OutMail
.To = stTo
.CC = stCC
.BCC = ""
.Subject = stSubject
.Body = "Hi," & vbCrLf & stMessage & vbCrLf
.Attachments.Add ActiveWorkbook.FullName
.DeleteAfterSubmit = True
.Send 'or use .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
MsgBox "Form has been sent"
If dbAdmin = 1 And dbType = 2 Then
On Error GoTo PrintError
If Range("I1").Value <> "" Then
wksKey.Visible = True
wksKey.Select
Activesheet.PrintOut
wksKey.Visible = False
wksCurrent.Select
Activesheet.PrintOut
End If
ElseIf dbAdmin = 0 Then
Button3 = MsgBox("Do you wish to save before workbook is closed as
your sent email has been deleted?", vbYesNo, "Save Workbook")
If Button3 = vbYes Then
UserForm4.Show
End If
End If
Continue:
ActiveWorkbook.Close False
PrintError:
MsgBox "Unable to print"
End
Error_MayCauseAnError:
Call UnProtectSheet
If dbAdmin = 0 Then
Sheets("Sheet1").cmdEmail.Visible = True
Application.Range("H6").Value = ""
End If
Application.Range("H7").Select
Call ProtectSheet
MsgBox "Not able to Email, " & vbCrLf & "check your mailbox is not full
or " _
& vbCrLf & "the system is not down.", vbOKOnly, "EMAIL ERROR"
End
SaveError:
MsgBox "Unable to save, please see Noemi", vbYesNo
End

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top