Solved

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

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

939 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

10 Experts available now in Live!

Get 1:1 Help Now