P
Pieter
I have this macro () works fine but i want to protect this
worksheet before i sent it to the emailaddress So the reciever can not change
my sheet. When i protect it the macro hungs and its not sending.
Wich code must i add?
gr:
Sub Mail_Loadingorder()
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Object
Dim OutMail As Object
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With ActiveSheet.UsedRange
.Value = .Value
End With
With wb
.SaveAs "Loadingorder " & Sheets("Loadingorder").Range("G1").Value _
& ".xls"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = ThisWorkbook.Sheets("Loadingorder").Range("e4").Value
.CC = ""
.BCC = ""
.Subject = "Loadingorder " &
Sheets("Loadingorder").Range("G1").Value
.Attachments.Add wb.FullName
'You can add other files also like this
'.Attachments.Add ("C:\Loadingorder.txt")
.Send 'or use .Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
worksheet before i sent it to the emailaddress So the reciever can not change
my sheet. When i protect it the macro hungs and its not sending.
Wich code must i add?
gr:
Sub Mail_Loadingorder()
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Object
Dim OutMail As Object
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With ActiveSheet.UsedRange
.Value = .Value
End With
With wb
.SaveAs "Loadingorder " & Sheets("Loadingorder").Range("G1").Value _
& ".xls"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = ThisWorkbook.Sheets("Loadingorder").Range("e4").Value
.CC = ""
.BCC = ""
.Subject = "Loadingorder " &
Sheets("Loadingorder").Range("G1").Value
.Attachments.Add wb.FullName
'You can add other files also like this
'.Attachments.Add ("C:\Loadingorder.txt")
.Send 'or use .Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
End Sub