Consulting

Results 1 to 7 of 7

Thread: How do I select more than one sheet and send as workbook

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular Erays's Avatar
    Joined
    Mar 2005
    Posts
    73
    Location

    Smile How do I select more than one sheet and send as workbook

    Option Explicit 
     
    Sub EmailandSaveCellValue() 
    'Variable declaration
    Dim oApp As Object, _ 
    oMail As Object, _ 
    WB As Workbook, _ 
    FileName As String, MailSub As String, MailTxt As String 
    'Set email details; Comment out if not required
    Const MailTo = "some1@someone.com" 
    Const MailCC = "some2@someone.com" 
    Const MailBCC = "some3@someone.com" 
    MailSub = "Please review " & Range("Subject") 
    MailTxt = "I have attached " & Range("Subject") 
    'Turns off screen updating
    Application.ScreenUpdating = False 
    'Makes a copy of the active sheet and save it to
    'a temporary file
    ActiveSheet.Copy 
    Set WB = ActiveWorkbook 
    FileName = Range("Subject") & " Text.xls" 
    On Error Resume Next 
    Kill "C:\" & FileName 
    On Error Goto 0 
    WB.SaveAs FileName:="C:\" & FileName 
    'Creates and shows the outlook mail item
    Set oApp = CreateObject("Outlook.Application") 
    Set oMail = oApp.CreateItem(0) 
    With oMail 
    .To = MailTo 
    .Cc = MailCC 
    .Bcc = MailBCC 
    .Subject = MailSub 
    .Body = MailTxt 
    .Attachments.Add WB.FullName 
    .Display 
    End With 
    'Deletes the temporary file
    WB.ChangeFileAccess Mode:=xlReadOnly 
    Kill WB.FullName 
    WB.Close SaveChanges:=False 
    'Restores screen updating and release Outlook
    Application.ScreenUpdating = True 
    Set oMail = Nothing 
    Set oApp = Nothing 
    End Sub
    Last edited by Erays; 03-18-2005 at 05:41 PM. Reason: Need help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •