Excel question

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

mad-martin

Thread Starter
Joined
Jul 5, 2002
Messages
1,321
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
 
Joined
Jul 25, 2004
Messages
5,458
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
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top