Solved

Excel macro : sending attachement to Outlook 2010 give execution error 440

Posted on 2016-10-03
3
38 Views
Last Modified: 2016-10-03
Dear All,

I have the macro below :

Sub Envoyer_Pointage_Préfac_GEFCO_Décade1()
'

    Sheets("RECAP DECADE 1").Select
    Sheets("RECAP DECADE 1").Copy
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:= _
        "c:\trash2\Pointage anomalies Préfac GEFCO Décade 1.xlsx", _
        FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("A1").Select
    Application.DisplayAlerts = False
    ActiveWorkbook.Save
    Application.DisplayAlerts = False
    ActiveWindow.Close
   
   
   
Application.DisplayAlerts = False
Worksheets("RECAP DECADE 1").Range("A1:C75").Select

               ActiveWorkbook.EnvelopeVisible = True
               With ActiveSheet.MailEnvelope
                   .Introduction = "Bonjour, Après le pointage de vos éléments de préfacturation, les anomalies en PJ ont été constatées. Merci de bien vouloir effectuer les vérifications qui s'imposent avant de rédiger vos factures sur chacun des comptes sur la base des montants ci-dessous. Cordialement"
                   .Item.To = "toto_danil@contoso.com"
                   .Item.CC = ""
                   .Item.Subject = "Pointage Préfac GEFCO Décade 1"
                   .Item.Attachments.Add = "c:\trash2\Pointage anomalies Préfac GEFCO Décade 1.xlsx"
                   .Item.Send
               End With



That :

select a sheet
copy that sheet to a new worksheet
Save it to a new worksheet name
Copy and paste a selection
save it
close the active workboot


I got th error message "execution error 440"
on the yellow line on the file attached

Any clues?
excelmacro.PNG
0
Comment
Question by:celmajj
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 500 total points
ID: 41826319
If you change the line that reads:

.Item.Attachments.Add = "c:\trash2\Pointage anomalies Préfac GEFCO Décade 1.xlsx"

to

.Item.Attachments.Add("c:\trash2\Pointage anomalies Préfac GEFCO Décade 1.xlsx")

or

.Item.Attachments.Add(Source:="c:\trash2\Pointage anomalies Préfac GEFCO Décade 1.xlsx")

...does the Error 440 still occur?
0
 

Assisted Solution

by:celmajj
celmajj earned 0 total points
ID: 41826408
Thks you. This works
I did'nt find any information from Microsoft relating the correct syntax
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 41826484
You are welcome.

This page may help:

[ https://msdn.microsoft.com/en-us/library/office/ff869553.aspx ]
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question