Reinstalando todo...
Public Enum eGestorCorreo
NotDefined = 0
Outlook
Notes
Firefox
End Enum
Public Enum eGestorCorreo
NotDefined = 0
Outlook
Notes
Firefox
EnumMax
End Enum
Public Enum eGestorCorreo
NotDefined = 0
Outlook
Notes
Firefox
[_EnumMax]
End Enum
Function RedondeaArriba(dblNumero As Double) As Long
' Función que toma un número con decimales y lo devuelve sin decimales como Long
RedondeaArriba = Int(dblNumero) + Abs(dblNumero > Int(dblNumero))
End Function
Public Function GetSeed(Tabla As String, Campo As String) As Long
Dim cat As Object
On Error Resume Next
Set cat = CreateObject("ADOX.Catalog")
' para otra base de datos externa a la actual
' sustituir CurrentProject.Connection por objecto ADODB.Connection ADODB
' conectado a la base externa
cat.ActiveConnection = CurrentProject.Connection
GetSeed = cat.Tables(Tabla).columns(Campo).Properties("Seed")
Set cat = Nothing
On Error GoTo 0
End Function
Public Function SetSeed(Tabla As String, _
Campo As String, _
SiguienteNumero As Long, _
Optional Intervalo As Long) As Boolean
Dim cat As Object
On Error Resume Next
Set cat = CreateObject("ADOX.Catalog")
' para otra base de datos externa a la actual
' sustituir CurrentProject.Connection por objecto ADODB.Connection ADODB
' conectado a la base externa
cat.ActiveConnection = CurrentProject.Connection
cat.Tables(Tabla).columns(Campo).Properties("Seed") = SiguienteNumero
If Intervalo <> 0 Then
cat.Tables(Tabla).columns(Campo).Properties("Interval") = Intervalo
End If
Set cat = Nothing
On Error GoTo 0
End Function
Set OUTAPP = CreateObject("Outlook.Application")
Set OUTMAIL = OUTAPP.CreateItemFromTemplate(Application.CurrentProject.Path & "\oficio.oft")
' oficio.oft es una plantila de mail con la firma
With OUTMAIL
.To = mail
.cc = ""
.bcc = ""
.BodyFormat = olFormatHTML
.Subject = "asunto del envio"
adjunto1 = Application.CurrentProject.Path & "\factura.pdf"
.Attachments.Add (adjunto1)
Sub MostrarVariables()
'Declaramos variables
'
Dim i As Integer
'
i = 1
'
'Mientras el valor de Environ NO sea vacío, se obtiene el valor.
While Environ(i) <> Empty
'
ActiveWorkbook.Sheets("Hoja1").Range("A8").Offset(i, 0).Value = Environ(i)
'
i = i + 1
'
Wend
'
End Sub
Public clnClient As New Collection 'Instances of frmClient.
Function OpenAClient()
'Purpose: Open an independent instance of form frmClient.
Dim frm As Form
'Open a new instance, show it, and set a caption.
Set frm = New Form_frmClient
frm.Visible = True
frm.Caption = frm.Hwnd & ", opened " & Now()
'Append it to our collection.
clnClient.Add Item:=frm, Key:=CStr(frm.Hwnd)
Set frm = Nothing
End Function
Function CloseAllClients()
'Purpose: Close all instances in the clnClient collection.
'Note: Leaves the copy opened directly from database window/nav pane.
Dim lngKt As Long
Dim lngI As Long
lngKt = clnClient.Count
For lngI = 1 To lngKt
clnClient.Remove 1
Next
End Function
Private Sub Form_Close()
'Purpose: Remove this instance from clnClient collection.
Dim obj As Object 'Object in clnClient
Dim blnRemove As Boolean 'Flag to remove it.
'Check if this instance is in the collection.
For Each obj In clnClient
If obj.Hwnd = Me.Hwnd Then
blnRemove = True
Exit For
End If
Next
'Deassign the object and remove from collection.
Set obj = Nothing
If blnRemove Then
clnClient.Remove CStr(Me.Hwnd)
End If
End Sub
Function DiaLabIntl(dtmFechaInicial As Date, intDiasProceso As Integer, Optional strTipoSemanaLaboral As String = "0000011", Optional blnAplicaFestivos As Boolean = True) As Date
' Función análoga a la de Excel utilizando el tipo de semana laboral como cadena y un boolean para aplicar laborables y festivos
' En caso de aplicar festivos será necesario indicar el nombre de la tabla y el campo de la tabla que contiene la fecha
' La cadena de strTipoSemanaLaboral se establece con 7 ceros y unos. El cero indica laborable y el uno festivo.
' Así, "0000011" indica el fin de semana de sábado-domingo. Esa técnica nos permite gestionar (casi) cualquier combinación
Const cTablaFestivos As String = "tblDatFestivos"
Const cCampoFecha As String = "FechaFestiva"
Dim dtmLaFecha As Date
Dim intdias As Integer
' Establecemos la fecha inicial
dtmLaFecha = dtmFechaInicial
' Bucle sin condiciones
Do
' Evaluamos si el día de la semana se ha estipulado como festivo.
If Mid(strTipoSemanaLaboral, Weekday(dtmLaFecha, vbMonday), 1) = "1" Then
' Es un NO-laborable: no hacemos nada
Else
' En este punto "parece" un laborable pero miramos si es festivo (si procede)
If blnAplicaFestivos And DCount("*", cTablaFestivos, cCampoFecha & "= " & CLng(dtmLaFecha)) > 0 Then
' es un festivo: nada
Else
' Ni es fin de semana, ni es festivo (sea porque no aplica, sea porque no lo es)
intdias = intdias + 1
End If
End If
' Comprobamos si hemos alcanzado el limite de días
If intdias >= intDiasProceso Then
DiaLabIntl = dtmLaFecha
Exit Function
End If
' Aumentamos un día
dtmLaFecha = DateAdd("d", 1, dtmLaFecha)
' Comprobación de seguridad
If dtmLaFecha > DateAdd("d", intDiasProceso + 1000, dtmFechaInicial) Then
MsgBox "Creo que nos hemos pasado de largo", vbExclamation
DiaLabIntl = "01/01/1900"
Exit Function
End If
Loop
End Function