Log in

View Full Version : Solved: File, Send To - Run a macro



mark_h82
05-11-2007, 08:08 AM
Hi, Is it possible to automatically run a macro when a user selects File, Send To and say mail recipient as attachment?

Or would I have to create my own menu item?

Marcster
05-11-2007, 12:11 PM
.

fumei
05-11-2007, 10:20 PM
Dot?

The answer is, yes, it is possible. You can overwrite the Word command.

Sub SendForReview()
'Overrides the File Send To Mail Recipient (for Review) command
' your code here
End Sub

Sub FileSendMail()
'Overrides the File Send To Mail Recipient (as Attachment) command
' your code here
End Sub

Of course, overwriting means ALL use of the command will do those instructions.

mark_h82
05-15-2007, 02:29 AM
I have tried adding this in to my Normal.dot and then when opening up another document and using this it does not seem to work.

This is the code I have wrote:

Sub FileSendMail()
'Overrides the File Send To Mail Recipient (as Attachment) command
' your code here

Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document

On Error GoTo myExit:

AGMAIN.OpenTrackChangesWarning

Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save
With EmailItem
.Subject = Doc.FullName
.Attachments.Add Doc.FullName
End With

Application.ScreenUpdating = True

Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing

myExit:

End Sub

Thanks, Mark

fumei
05-16-2007, 03:43 PM
I can see something wrong, but as you use that useful phrase "does not 'work", I will wait until you clearly state what that means.