Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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 …

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now