We help IT Professionals succeed at work.

Outlook Macro does not run when doing a "Send to" in Excel/Word

Medium Priority
505 Views
Last Modified: 2013-11-25
I have an Outlook macro that prompts the user for confirmation on sending a message with an attachment to an external domain.
This macro works great in Outlook.  It does not work when doing a "Send To" in any office application.
Please tell me I don't need a macro for every office application...
Please help!
Comment
Watch Question

Top Expert 2012

Commented:
Which Version of Office are you using?

Author

Commented:
Using Office 2003
Top Expert 2012

Commented:
Great, I believe the following works for 2003.

Right Click Start and go to Explore
Navigate to :
C:\Documents and Settings\Username

*Make sure your view is set to show Hidden Files and Folders

Click on the SendTo Folder

On the right
Create a New Shortcut
Location should be:  "C:\Program Files\Microsoft Office\Office11\OUTLOOK.EXE" /a
Next
Name it accordingly, something you will recognize. (Example: WORD EXCEL EMAIL)
Finish

Now in Word or Excel when you use Send To this new shortcut option should be available.
Using this one, your macro should work.

Author

Commented:

Thanks for the help so far but I'm a little confused
I created the shortcut in the folder you suggested.  It is pointing to the outlook application (which is same location but actually on our d drive)
I'm not sure where I should see the shortcut appear now?   Will this change the current Send To functionality?
I am deploying this to 300 users by lowering macro security and copying the outlook macro file to their PC via a logon script.
I have attached the code for reference, not sure it is needed though.

Thanks again for the help!

Author

Commented:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim prompt As String
    Dim myInspector As Outlook.Inspector
    Dim myItem As Outlook.MailItem
    Dim myAttachments As Outlook.Attachments
    Dim ExtEmailAddress As Boolean
    Dim Totalrecipients As Integer
    Dim Count As Integer
    Dim ToList As String
    
    Set myInspector = Application.ActiveInspector
    ExtEmailAddress = False
    
    If Not TypeName(myInspector) = "Nothing" Then
        If TypeName(myInspector.CurrentItem) = "MailItem" Then
            Set myItem = myInspector.CurrentItem
            Set myAttachments = myItem.Attachments
                     
            'Check for an external email address (if an smpt format then external)
            Totalrecipients = myItem.Recipients.Count
            For Count = 1 To Totalrecipients
                If InStr(myItem.Recipients.Item(Count).Address, "@") Then
                    ToList = ToList & myItem.Recipients.Item(Count).Address & vbCrLf
                    ExtEmailAddress = True
                End If
            Next
                        
            'If there are attachments and an external email address exists then prompt the user
            If myAttachments.Count > 0 And ExtEmailAddress = True Then
                prompt = "This email contains an attachment(s) and it is being sent to the following external addresses: " _
                & vbCrLf & vbCrLf & ToList & vbCrLf & "Are you sure you want to send these " _
                & myAttachments.Count & " attachments to these external recipients?"
                If MsgBox(prompt, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "***Warning***") = vbNo Then
                    Cancel = True
                End If
            End If
        End If
    End If
End Sub
Private Sub Application_Startup()
    'This section is required to initialize macro's on startup
End Sub

Open in new window

Author

Commented:
Ok, forgive the slowness in me catching on....but I do see what you were refereing to now, that was using Send To from windows explorer when right clicking on the file.
Your suggestion did help a great deal here.  I deleted the Mail Recipient File and then renamed my macro as the same name.   This allows my macro to run when doing the send to from explorer...so that is great!!!
Now I need to figure out how to disable the send to in the office application itself, or get my macro to run from there.

Author

Commented:
Sorry, I meant to say I used your shortcut Idea with outlook /a as an an option to launch when right clicking on a file,  NOT my macro file...in any case that part is now completed.
Top Expert 2012

Commented:
Sorry, thought it would add this shortcut as an option in Word or Excel Send To. It doesnt.

However, If you save the Word or Excel Document, say to your desktop.
Right click on the Word or Excel file.
Go to Send To>
Here you will see your newly created Outlook Send To Shortcut.
Selecting it this way will create a new mail item with this file attached and macro should still run.



Author

Commented:
Your idea was helpful as it helped me resrict the "Send To" feature from the file system level, as in from the desktop or windows explorer.
I need to find a way to enable my macro or disable the Sent To feature from the applications then.
Any idea on where I could go next?
Top Expert 2012

Commented:
Considering that Word and Excel use MAPIMAIL for Send To.
Here is the registry location to fix it, if they didnt work.

http://support.microsoft.com/kb/918792

However, since we are wanting to diable this option, im thinking would need to somehow do the opposite or set the settings to 0.


Top Expert 2012

Commented:
Setting the following to 0 does make option in Word and Excel Unavailable

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Messaging Subsystem

MAPI REG_SZ  1
MAPIX REG_SZ  1
OLEMessaging REG_SZ  1

Author

Commented:
Thanks, is very helpful!   If we can not find a way to get the macro from the MAPIMAIL, then I will present disabling this feature as the only other alternative.
Is there any way you can think of on how we can accomplish this?

Author

Commented:
This also only hides the "Send To" "Mail Recipient (as attachment)".   It does not appear to hide "Mail Recipient" nor "Routing Recpient" options which still work.
Top Expert 2012
Commented:
Sorry, left one out.

Try Setting
CMC REG_SZ  1

to 0

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
I have changed that key also but it doesn't seem to remove the hide "Mail Recipient" nor "Routing Recpient" options.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.