Consegui corrigir o funcionamento
Precisei utilizar apenas:
***********************************************************************************************************
Sub Send_MailJust()
Dim oApp As Object
Dim oMail As Object
Dim WB As Workbook
Dim FileName As String
' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVisible = False
'Turn off screen updating
Application.ScreenUpdating = False
Sheets("Form-Just").Unprotect
ActiveSheet.Range("D10").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Range("D12").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Form-Just").Range("A1:M70").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ActiveSheet.Copy
Set WB = ActiveWorkbook
FileName = "Justificativa - " & ActiveSheet.Range("N16") & ".xls"
On Error Resume Next
Kill "C:Temp" & FileName
On Error GoTo 0
WB.SaveAs FileName:="C:Temp" & FileName
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
' .Introduction = "Formulario de Justificativa - (" & ActiveSheet.Range("D20") & ")"
.To = ActiveSheet.Range("O12")
.CC = ActiveSheet.Range("O10")
.Subject = "[FORMULARIO DE JUSTIFICATIVA] - " & ActiveSheet.Range("D10") & ActiveSheet.Range("E13") & ActiveSheet.Range("F13")
.Attachments.Add WB.FullName
If MsgBox("Deseja realmente enviar a mensagem?", vbYesNo, "Notificação Automática") = vbNo Then
MsgBox "Envio cancelado pelo usuario!" & vbCrLf & "Feche o Arquivo sem Salvar!" & vbCrLf & "Em Seguida clique no Botão Cancelar!"
Exit Sub
Else
Application.DisplayAlerts = False
Sheets("Form-Just").Unprotect
.Send
Sheets("Form-Just").Protect , Contents:=True
WB.ChangeFileAccess Mode:=xlReadOnly
Kill WB.FullName
WB.Close SaveChanges:=False
End If
End With
Mensagem = MsgBox("Email Enviado com Sucesso, verifique seus itens enviados!", vbOKOnly, "Notificação Automática")
ActiveWorkbook.EnvelopeVisible = True
ActiveWorkbook.EnvelopeVisible = False
Sheets("Form-Just").Unprotect
Sheets("Form-Just").Protect , Contents:=True
Set oMail = Nothing
Set oApp = Nothing
Application.Quit
Application.DisplayAlerts = False
End Sub
***********************************************************************************************************
Quem quiser testar apenas crie a pasta C:Temp ou adicione uma rotine que crie o diretório, eu precisei criar porque tenhos restrições de acesso na máquina
[]s
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 27/12/2011 4:25 pm