Problem with Macro

bms8276

New Member
Joined
Mar 29, 2006
Messages
9
I have the following macro but i it doen't seem to work please help. The macro falls down at outlook reference.

I have enabled the reference Microsoft outlook 10.0 object library,

PLEASE HELP!!!

Code:
Sub Mail_New_Deal_Customer()

Sheets("New Deal").Copy
Nametosave = Cells(2, 3).Value & " " & Cells(3, 4).Value

    Application.DisplayAlerts = False


    ActiveWorkbook.SaveAs Filename:= _
        "\\C:\Documents and Settings\user\Desktop\W Communications Operations Model\" + Nametosave, FileFormat:=xlNormal, _
        Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
        CreateBackup:=False
          
    Application.DisplayAlerts = True
    
    Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    ActiveWorkbook.Save

'This example send the last saved version of the Activeworkbook
'You must add a reference to the Microsoft outlook Library
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    With OutMail
        .To = Cells(63, 5).Text
        .CC = ""
        .BCC = ""
        .Subject = "New Deal  " & Cells(3, 4).Text
        .Body = "Please find enclosed details of your new mobile contract for your consideration. If you have any discrepancies or any queries please contact" & Cells(63, 11).Text
        .Attachments.Add ActiveWorkbook.FullName
        .Attachments.Add ("C:\Documents and Settings\user\Desktop\W Communications Operations Model\Current Tariffs\" & Cells(9, 22).Text & ".pts")
        'You can add other files also like this
        '.Attachments.Add ("C:\test.txt")
        .send   'or use .Display
    End With
    Set OutMail = Nothing
    Set OutApp = Nothing

ActiveWorkbook.Close
End Sub

EDIT: Added Code tags - Moderator
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,214,400
Messages
6,119,292
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top