Jump to content

Formulario con Error 1004


ceron28

Recommended Posts

Amigos buenas tardes, tengo la siguiente macro que valida la información de un formulario y en caso de que esté correctamente diligenciado, crea un correo de Outlook y adjunta el formulario; sin embargo me aparece el error 1004 en tiempo de ejecución, la verdad no encuentro el error por lo que les agradecería me ayudaran.

De antemano gracias!!!

Sub Enviar()

'variable para "manejar" el objeto Outlook

Dim OutApp As Object

'variable para "manejar" el objeto mail

Dim OutMail As Object

'creamos el objeto Outlook, para acceder a sus propiedades, métodos y eventos:

Set OutApp = CreateObject("Outlook.Application")

'logeamos: ojo acá, debemos tener la cuenta bien configurada

OutApp.Session.logon

'creo el mail

Set OutMail = OutApp.CreateItem(0)

Dim ok As Boolean

ok = False

If Range("c5").Value = "" Or Range("c6").Value = "" Or Range("c7").Value = "" Or Range("c10").Value = "" Or Range("c11").Value = "" Or Range("c12").Value = "" Or Range("c13").Value = "" Or Range("c14").Value = "" Or Range("c19").Value = "" Or Range("c20").Value = "" Or Range("c21").Value = "" Or Range("c22").Value = "" Or Range("c24").Value = "" Or Range("c26").Value = "" Or Range("c27").Value = "" Or Range("c28").Value = "" Or Range("c35").Value = "" Then

If MsgBox("Todos los campos deben diligenciarse, Por favor verificar para enviar el evento", vbCritical, "ERROR") = vbOK Then

Range("c5").Select

End If

Else

ok = True

If Range("c19").Value <> "NO APLICA O NO DISPONIBLE" Then

If Range("d19").Value = "" Then

If MsgBox("Debe digitar el número de identificación", vbCritical, "ERROR") = vbOK Then

Range("d19").Select

ok = False

End If

End If

End If

End If

If Range("c26").Value < Range("c27") Then

If MsgBox("La fecha de descubrimiento debe ser posterior a la fecha de inicio del evento", vbCritical, "ERROR") = vbOK Then

Range("c26").Select

End If

ElseIf Range("c27") > Range("c28") Then

If MsgBox("La fecha de inicio debe ser anterior a la fecha de finalización del evento", vbCritical, "ERROR") = vbOK Then

Range("c27").Select

End If

Else

If ok = True Then

'y acá comienza el "proceso de envío"

Application.Sheets("Codificación").Visible = xlVeryHidden

Oficina = Sheets("Reporte de Eventos SARO").Range("C5").Value

Fechac = Format(Date, "dd-mm-yyyy")

ActiveWorkbook.SaveAs "C:\REPORTE EVENTOS SARO" & " " & "-" & " " & Oficina & " " & Fechac & ".xls"

On Error Resume Next

With OutMail

.To = Range("H9").Value 'a quien se lo envío

.CC = Range("H8").Value 'si queremos agregar alguna copia

.BCC = "" 'si queremos agregar alguna copia oculta

.Subject = "REPORTE EVENTOS SARO" & " " & "-" & " " & ([C5]) & " " & ([C7]) 'el asunto

.Body = Range("H10").Value 'cuerpo del mensaje

.Attachments.Add ActiveWorkbook.FullName 'adjunto el archivo actual

.Display

End With

End If

End If

End Sub

Link to comment
Share on other sites

Cual es la linea que te da el error?? Deberías subir tu archivo de referencia para poder ayudarte Ayuda Excel - Normas punto 5.

Lo que puedes hacer es sobre ese código preciosa F8 el código se ira ejecutando paso a paso hasta llegar al error y sera mas fácil para que lo identifiques..

Salu2

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

Privacy Policy