Solved

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

Posted on 2016-10-03
3
44 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

821 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