ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Email Help (https://www.excelbanter.com/excel-programming/340879-email-help.html)

Alex Martins[_2_]

Email Help
 
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 "
ActiveWorkbook.Close
End Sub

JNW

Email Help
 
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 procedu

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 = "
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


"Alex Martins" wrote:

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 "
ActiveWorkbook.Close
End Sub



All times are GMT +1. The time now is 05:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com