Código VB para solamente abrir outlook
Tengo el siguiente código
Sub CORREO_INCIDENCIAS()
Application.ScreenUpdating = False
If Range("b2").Value = "NO" Then
MsgBox "Faltan campos importantes para continuar, Verificalo!", vbCritical, "ERROR"
Exit Sub
End If
If Range("E8") = Empty Then
MsgBox "No anotaste nada en CUERPO DE MENSAJE", vbInformation, "AVISO"
End If
If Range("D38") = Empty Then
MsgBox "No anotaste nada OBSERVACIONES", vbInformation, "AVISO"
End If
ActiveSheet.Unprotect
[f37].ClearContents
reporte = MsgBox("¿Enviar Reporte de incidencias de:" & [J13] & " " & [m13 ] & " " & [n13] & " ?" & vbCr _
& " Para: " & UCase([E2]), vbExclamation + vbYesNo, "OUTLOOK")
If reporte = vbYes Then
'por.Dante Amor
'Enviar una hoja por correo
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'
ActiveSheet.Range("AB13").Select
Set h2 = ActiveSheet
wpath = ThisWorkbook.Path & "\"
Nombre = h2.Name & [J13] & [n13]
'u = h2.Range("C" & Rows.Count).End(xlUp).Row 're-impresion
'h2.PageSetup.PrintArea = "$A$1:$AF$" & u 're-impresion
'actPrnt = Application.ActivePrinter 'IMPRESION're-impresion
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=wpath & Nombre & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set L1 = ThisWorkbook
Set h1 = ActiveSheet 'Sheets("INCIDENCIAS")
CEL = h1.[BQ3]
CEL2 = h1.[BO3]
CEL3 = h1.[CA1]
ruta = L1.Path & "\"
Set l2 = Workbooks.Add
Set h2 = l2.Sheets(1)
'Sheets("ESTADO DE CUENTA").Cells.AutoFilter
h1.Range("C12:AA40").Copy
h2.[A1].PasteSpecial Paste:=xlValues
h2.[A1].PasteSpecial Paste:=xlPasteFormats
l2.SaveAs Filename:=ruta & h1.Name & ".xlsx", FileFormat:=xlOpenXMLWorkbook
l2.Close
'
Set dam = CreateObject("outlook.application").CreateItem(olMailItem) '
dam.To = h1.Range("E2")
dam.CC = h1.Range("E4")
dam.BCC = "[email protected]"
dam.Subject = h1.Range("E6") & " DEPTO. " & [J13] & " " & [d13]
dam.Body = h1.Range("E8") & " Posteriormente enviare el reporte con las firmas originales, de no ser asi favor de reportarse ATTE: " & [L40]
dam.Attachments.Add ruta & h1.Name & ".xlsx"
dam.Attachments.Add wpath & Nombre & ".pdf"
'dam.send
dam.display
MsgBox "Incidencia enviada con exito", vbInformation, "INCIDENCIAS"
DoEvents
Kill wpath & Nombre & ".pdf"
Kill ruta & h1.Name & ".xlsx"
DoEvents
Range("I10").Value = Range("I10").Value + 1
[J10].Value = Now
ActiveSheet.Protect
' IMPRIMIR_INCIDENCIAS
End If
End Subeste codigo me funciona perfectamente como esta... El detalle es que primero tengo abrir outlook para que se pueda ENVIAR.. Ya que si lo ejecuta tal como esta sin abrir antes OUTLOOK este me lo dejare en la bandeja de salida y no lo enviara...
Por eso quería saber si se puede solucionar el detalle con una macro que abra OTULOOK automáticamente al abrir el archivo excel donde tengo el código...
1 Respuesta
Respuesta de Abraham Valencia
1
