ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Email macro (https://www.excelbanter.com/excel-discussion-misc-queries/170166-email-macro.html)

Kevin

Email macro
 
can anyone find the flaw??

here's my macro and here's the issue. I've tested this with three
computers, two work and one does not, i get a Run-time error 1004.

Run-time error'1004':
Microsoft Office Excel cannot access teh file 'N:'. There are several
possible reasons:

The file name or path does not exist
The file name is being used by another program.
the workbook you are tryig to save has the same name as a currently open
workbook.



Calculate
Dim OutApp As Object
Dim OutMail As Object
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yyyy-mm-dd")
Application.ScreenUpdating = False
Sheets("Emailed").Visible = True
Sheets("Emailed").Select
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs ThisWorkbook.Name & " " & strdate & ".xls"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(o)
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "New Accounts Activity"
.Body = "Please do a 'Paste Special' and choose 'Values and
Number Formats'"
.Attachments.Add wb.FullName
.Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Sheets("Emailed").Select
ActiveWindow.SelectedSheets.Visible = False
Set OutMail = Nothing
Set OutApp = Nothing
End Sub


All times are GMT +1. The time now is 03:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com