1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Excel question

Discussion in 'Business Applications' started by mad-martin, Nov 3, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. mad-martin

    mad-martin Thread Starter

    Joined:
    Jul 5, 2002
    Messages:
    1,309
    Hi all,

    I have a question...

    At work I have to email loads of excel worksheets to customers on a regular basis.
    To make it myself a bit easier I added a hyperlink with the customers email address in the worksheet. Now I was thinking... it would be handy that, when you click the hyperlink, it automatically would open outlook and attach the current worksheet.

    Any of you smart guys/gals got an idea?? I know that more than likely it can't be done with a hyperlink, but perhaps a bit of code?

    What am I rambling... you guys are the experts!

    Cheers for reading! :D
     
  2. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
  3. kirbs_ph

    kirbs_ph

    Joined:
    Oct 29, 2007
    Messages:
    10
    have you tried File > Send to > Mail File (as Attachment)?
     
  4. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Hi there,

    I use a slightly different approach, but implemented with the RangetoHTML function...

    Code:
    Sub SendRange()
        Dim olApp As Object, olMail As Object, olMailItem As Object
        Dim rngeSend As Range, blnCreated As Boolean
        If ActiveWorkbook Is Nothing Then
            MsgBox "You have no open workbook!", vbExclamation, "ERROR!"
            Exit Sub
        End If
        On Error Resume Next
        Set rngeSend = Application.InputBox("Please select range you wish to send.", _
                     , Selection.Address, , , , , 8)
        If rngeSend Is Nothing Then Exit Sub    'User pressed Cancel
        '// Changes by Zack Barresse
        Call ToggleEvents(False)
        Set olApp = GetObject(, "Outlook.Application")
        blnCreated = False
        If olApp Is Nothing Then
            Set olApp = CreateObject("Outlook.Application")
            blnCreated = True
        End If
        olApp.Session.Logon
        Set olMail = olApp.CreateItem(0)
        olMail.HTMLBody = RangetoHTML(rngeSend)
        olMail.Display
        If blnCreated = True Then olApp.Quit
        Call ToggleEvents(True)
        Exit Sub
    Sorry:
        MsgBox "Sorry you cannot execute this command!" & vbCr & _
               "Outlook is NOT installed" & DNL & _
               "Check out this site: " & NL & _
               "http://www.rondebruin.nl/cdo.htm", vbCritical + vbSystemModal, "Install Outlook"
    End Sub
    Also, if Outlook is not installed (which this code uses), there is an error message pointing the way for the CDO method which works without an email client, quite slick actually.

    HTH
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/647218

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice