Email Help

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

Guest

What I show below is the code I am using to save a copied and exported
workshet. What I want it to do is to send the email after the new workbook is
saved.

any help will be much obliged. I tried Ron deBruin's site and I am not
profficient enough to understand what may be going wrong.

many thanks in advance!!!!!!!
Alex

Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+Shift+S
'
Sheets("ACTUAL Q").Select
Sheets("ACTUAL Q").Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Call finish
End Sub
Sub finish()
Dim sBase As String
Dim sFile As String
sBase = Range("a28").Value
sFile = "c:\PROYECTO FA\" & sBase & ".xls"
ActiveWorkbook.SaveAs sFile
ActiveWorkbook.SendMail "(e-mail address removed)"
ActiveWorkbook.Close
End Sub
 
First clean up the copy code. If you are looking to just copy the sheet all
you need is:
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+Shift+S
'
Sheets("ACTUAL Q").Select
Sheets("ACTUAL Q").Copy
Call finish
End Sub

Sub finish()
Dim sBase As String
Dim sFile As String
sBase = Range("a28").Value
sFile = "c:\PROYECTO FA\" & sBase & ".xls"
ActiveWorkbook.SaveAs sFile
Call email
End Sub

If you use outlook add the following procedure:

Sub Email()
Application.ScreenUpdating = False
'This example send the last saved version of the Activeworkbook
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Object
Dim OutMail As Object
Dim EmailAddr As String
Dim Subj As String
Dim BodyText As String

EmailAddr = "(e-mail address removed)"
Subj = "Your subject"
BodyText = "Your Body"

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

With OutMail
.to = EmailAddr
.CC = ""
.BCC = ""
.Subject = Subj
.Body = BodyText
.Attachments.Add ActiveWorkbook.FullName
.Display 'or use .send to send automatically
End With

Set OutMail = Nothing
Set OutApp = Nothing

Activeworkbook.save
Activeworkbook.close
Application.ScreenUpdating = True
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

Similar Threads

Macro Related to Paste Values 2
Runtime 1004 Error Help Request 1
More efficient code than this? 3
Copy item from Outlook to folder via Excel 12
conso macro 0
VBA Formula Help 5
Copy/Paste Values code 12
Please help! 3

Back
Top