Consulting

Results 1 to 5 of 5

Thread: mail a workbook

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    mail a workbook

    hello
    this is johnske's send a workbook macro.i want to add a new feature through a msgbox.the size in bytes of the workbook and wheter it is to big to be sent in one piece.namely does it exceed the allow size by the email software.

    [VBA]Sub EmailDialog()
    ' 'Send workbook as attachment
    ' '//Show the dialog, insert recipients and subject\\
    Application.Dialogs(xlDialogSendMail).Show _
    "aaa@bbb.com; xxx@yyy.com;", _
    "Subject", True '< True = download messages
    End Sub[/VBA]thanks
    moshe

  2. #2
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    [vba]
    Option Explicit
    Sub EmailDialog()
    ' 'Send workbook as attachment
    ' '//Show the dialog, insert recipients and subject\\
    Const lngMaxBytes_c As Long = "5242880" '(5MB)
    ActiveWorkbook.Save
    If VBA.FileLen(ActiveWorkbook.FullName) > lngMaxBytes_c Then
    If _
    MsgBox("This file is larger than is preferred. Do you wish to send anyway?", _
    vbYesNo Or vbQuestion Or vbSystemModal Or vbDefaultButton1, _
    "Caution") = vbNo Then
    Exit Sub
    End If
    End If
    Application.Dialogs(xlDialogSendMail).Show _
    "aaa@bbb.com; xxx@yyy.com;", "Subject", True '< True = download _
    messages
    End Sub


    [/vba]
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  3. #3
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location
    hello
    this is johnske's macro.it allow a user to send activesheet by email.
    [VBA]
    Sub Mail_ActiveSheet()
    Dim wb As Workbook
    Dim strdate As String
    strdate = Format(Now, "dd-mm-yy h-mm-ss")
    Application.ScreenUpdating = False
    ActiveSheet.Copy
    Set wb = ActiveWorkbook
    With wb
    .saveas "Part of " & ThisWorkbook.name _
    & " " & strdate & ".xls"
    .SendMail "rafi@matnasim.org.il", _
    "activesheet excel sent"
    .ChangeFileAccess xlReadOnly
    Kill .FullName
    .Close False
    End With
    Application.ScreenUpdating = True
    End Sub

    [/VBA]
    how can i let the user send the activesheet to several addresses separated by comma.could it be doen through inputbox?
    thanks
    moshe

  4. #4
    Quote Originally Posted by lior03
    hello
    this is johnske's send a workbook macro.i want to add a new feature through a msgbox.the size in bytes of the workbook and wheter it is to big to be sent in one piece.namely does it exceed the allow size by the email software.

    [VBA]Sub EmailDialog()
    ' 'Send workbook as attachment
    ' '//Show the dialog, insert recipients and subject\\
    Application.Dialogs(xlDialogSendMail).Show _
    "aaa@bbb.com; xxx@yyy.com;", _
    "Subject", True '< True = download messages
    End Sub[/VBA]thanks
    Quick question. How would I insert multiple users? Such as adding people to the TO and CC lines in the email

  5. #5
    question....If I wanted to add a CC line how would I do that? Thanks

Posting Permissions

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