View Single Post
  #4   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default "Send As" add-in for Word?

The document will have to be saved in order to attach it. Whether you save
it manually or by using a built-in function as in OpenOffice or
transparently by using a macro to emulate that is really immaterial. The
following will send docx format documents as doc format attachments.

Sub Send_As_Mail_Attachment()
' send the document as an attachment _
in an Outlook Email message
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
Dim sDocName As String, sFname As String
On Error Resume Next
'Prompt the user to save the document
ActiveDocument.Save
sFname = ActiveDocument.FullName
sDocName = Left(sFname, InStr(1, sFname, ".doc"))
'Save as DOC format
ActiveDocument.SaveAs sDocName & "doc", wdFormatDocument97
'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
'Outlook wasn't running, start it from code
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.Attachments.Add Source:=ActiveDocument.FullName, _
Type:=olByValue, DisplayName:="Document as attachment"
.Display
End With
'Clean up
'Close the doc format document (you could delete it too if required)
ActiveDocument.Close
'Re-open the docx format document
Documents.Open sFname
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"Gordon" wrote in message
...

"Graham Mayor" wrote in message
...
Word 2007 already includes this ability. Set the default save format as
Word 97-2003 document format and Use Send E-Mail.


That's not /quite/ what I meant. What I mean is, I like to keep all my
documents as .docx documents. There are people I know who cannot install
the Compatibility pack and use 2003. (Corporate users). This means that I
have to do a "Save As" into .doc format before I send a document to them.
What Open Office has is a function that does "Send As .doc format" - no
matter whether the original is .odt or .docx. The original document is
unaltered, there are no duplicate documents in different formats, and I
can use the document format I want, not what is dictated by other users.

Hope that's a bit clearer!