Hi,
With a macro I copy a sheet out of the workbook and create a new one.
I then want this new sheet to have the following macro:
Private Sub Mail()
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Set olApp = CreateObject("Outlook.Application")
Err.Clear
End If
On Error GoTo 0
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.Subject = Range("A1") & " " & Range("A3")
.To = Range("A8")
.CC = Range("A9")
.Attachments.Add ThisWorkbook.FullName
.Display
End With
End Sub
Until now I have a userform that gets copied as well.
But it will then refer to and also attach the old workbook, how can I change that ? Since the new workbook has a naming policy (date, name etc) it's never the same and cannot be used directly.
Bookmarks