+ Reply to Thread
Results 1 to 2 of 2

Attach single sheet to outlook not entire book

  1. #1
    Forum Contributor
    Join Date
    01-14-2010
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    125

    Attach single sheet to outlook not entire book

    I am very much a beginner to vba.
    I have an excel file set-up, so once someone enters information on a worksheet they use a push button and it attaches the file to an e-mail and populates the to/cc fields based on entries they made and some default names that always receive the file.
    It works perfectly... the problem I am having is it not only attaches the active worksheet but the entire workbook which some individuals don't need to be receiving. How can I alter the code to only attach the active worksheet (with the sender's changes of course) to the e-mail and not all the pages of the workbook. I don't know how to alter my data in the upper right corner of postings but I recently started using Excel 2007. Thanks in advance! See below for the code

    'Sends e-mail of X form to person in cell B5 and will cc people x and y
    Sub SendMail()
    Dim rng As Range
    Dim OutApp As Object
    Dim OutMail As Object
    With Application
    .EnableEvents = False
    .ScreenUpdating = False
    End With

    Set rng = Nothing
    Set rng = ActiveSheet.UsedRange

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


    On Error Resume Next
    With OutMail
    .To = Range("B5")
    .CC = ""
    .BCC = ""
    .Subject = ""
    .HTMLBody = ""
    .Attachments.Add ActiveWorkbook.FullName
    .Display
    End With
    On Error GoTo 0
    End Sub

  2. #2
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: Attach single sheet to outlook not entire book

    Hi

    If I understood your question well, one option can be to copy only the required sheet to a new excel file, and mail that file?

    Or, create a copy of this file, delete unwanted sheets, and mail the file?

    hth
    Ajay

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1