Thread: Email macro
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Kevin Kevin is offline
external usenet poster
 
Posts: 504
Default 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