Sending as attachment

M

matt

Hi all,
I have some code that send the document as an attachment throught Outlook.
The file contains many linked objects to excel files and such. The problem is
when i send the document(I have security set-up with a password and all) and
the receiver recieves the attachment they still have the option to update the
links. Is the a way to send it as like an image of the document which would
remove all the links and just have say "placeholders" for them without being
linked?

'SEND REPORT AS ATTACHMENT
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = GetObject(, "Outlook.Application")

If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olmailitem)

Dim iDay As Integer
Dim iMonth As Integer
Dim dtYesterday As Date
dtYesterday = DateAdd("d", -1, Now)
iDay = DatePart("d", dtYesterday)
iMonth = DatePart("m", dtYesterday)


'Here you can edit the To:, CC:, and Subject: of the mail item
With oItem
.To = InputBox("Fill-In who you would like to send this Report to.",
"To:", "(e-mail address removed)")
.CC = InputBox("Would you like to CC: this email to someone?" &
vbCrLf & _
vbCrLf & "If yes fill-in who you would like to CC: the email
to and click OK:" & vbCrLf & "Else just click Cancel.", "CC:")
.Subject = InputBox("Fill-in the subject for this email:",
"Subject:", ".COM Daily Operational Report " & _
CStr(iDay) & "-" & MonthName(iMonth) & "-" & Year(Date))
'Add the document as an attachment
'you can use the .displayname property to set the description that's
used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue,
DisplayName:="Document as attachment"
.Display
'.Send
End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub
_____________________

SOME LINES ARE CUT SHORT...
 
D

Doug Robbins - Word MVP

Use an ActiveDocument.Fields.Unlink command before the document is attached.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
M

matt

Hey Doug thanks for the response.
Where do I add "ActiveDocuments.Fields.Unlink"?
I added it the line before this, where it says:
..Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
DisplayName:="Document as attachment"

Before I did that I made a copy in a differnet location(just to make sure
nothing happened to my origional document), and what happened was when I ran
that macro it unlinked the fileds from the original document. Is there a
different location where I am supposed to add the line? Or is that gona
happen no matter what?
Because I want to keep the links, but I just wnat to send it with them so
the person who recieves it can't mess with the links in the document.

Thanks,
Matt
 
D

Doug Robbins - Word MVP

It's not a matter of where you place the code, I think that you got that
right, but that the document that you want to send must be the active
document when the macro is run. It sounds like you have the copy that you
had made as the active document.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top