View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Neil Deinhardt Neil Deinhardt is offline
external usenet poster
 
Posts: 1
Default email shortcut to active workbook as an outlook attachment

I work on a network with clients that are all running Windows NT4 and
Excel 97, but with a mix of Outlook 98 and 2000 (don't ask...). I'm
trying to develop a VBA procedure that runs from a command button in
an Excel workbook template. I would like the procedure to save and
email a shortcut to the active workbook (which resides on a file
server). So far, my attempts have failed miserably. I can get the
procedure to work by sending the actual file, but I cannot get it to
send a shortcut - the shortcut appears in the mail message at furst,
but disappears after it is sent.

The code I am using is as below:

Public Sub SendLink()
Dim oOutlook As New Outlook.Application
Dim oMessage As Outlook.MailItem
Dim wReviewSheet As Excel.Worksheet
Set oMessage = oOutlook.CreateItem(olMailItem)
ThisWorkbook.Save
With oMessage
.Subject = "Subject line text"
.Body = "Email body text"
.Display
.Attachments.Add ThisWorkbook.FullName, olByReference
End With
End Sub

As I have the Outlook 2000 email client, I have added the reference
for the Outlook 9.0 library.

The problem seems to relate to the olByReference property of the Add
method. If I use olByValue, the attachment is preserved after sending,
but is a copy of the actual file, not a shortcut.

The other thing I'm not sure of is whether this will work with clients
that have the Outlook 98 email client. I've added a reference to the
Outlook 9.0 library - will the other clients require access to the
Outlook 8.0 library?

Thanks in advance for any help on this issue,

Neil