Sub Imagen13_Haga_clic_en()
Dim Izq As Single, Arr As Single, Ancho As Single, Alto As Single
Dim rutaArchivo As String
Dim Email As CDO.Message
Dim t As Single
Application.DisplayAlerts = False
Application.ScreenUpdating = False
ActiveSheet.Unprotect "4324"
'--- GENERAR IMAGEN DEL RECIBO ---
With Range("H7:R34")
Izq = .Left: Arr = .Top: Ancho = .Width: Alto = .Height
.CopyPicture
End With
With ActiveSheet.ChartObjects.Add(Izq, Arr, Ancho, Alto)
.Activate
.Chart.Paste
'---- RUTA DEL ARCHIVO (CORREGIDO) ----
rutaArchivo = "C:\Users\Usuario\Google Drive\LOCACIONES\REC. PROPIETARIOS\" & _
Format(Range("Q20"), "mmmYY") & " - " & _
Range("Q9") & " - " & _
Range("P17") & " - " & _
Range("K19") & ".JPG"
.Chart.Export rutaArchivo
.Delete
End With
'Guardar ruta en AK30 por compatibilidad
Range("AK30").Value = rutaArchivo
'--- PEGAR BLOQUE DE DATOS ---
Range("AH6").Copy
Range("AH9").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Range("Y7:AI33").Copy
Range("H7").PasteSpecial xlPasteAll
ActiveSheet.Protect "4324"
ActiveWorkbook.Save
'--- PREPARAR ENVÍO DEL MAIL ---
Set Email = New CDO.Message
correo_origen = "nqn.negocios@gmail.com"
Clave_correo_origen = "wkfhaapcnjljbwju"
correo_destino = Range("AK27").Value
Asunto = Range("AK28")
Mensaje = Range("AK29")
Email.Configuration.Fields(cdoSMTPServer) = "smtp.gmail.com"
Email.Configuration.Fields(cdoSendUsingMethod) = 2
With Email.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = correo_origen
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Clave_correo_origen
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
End With
'--- VALIDAR ARCHIVO ANTES DE ENVIAR ---
t = Timer
Do While Dir(rutaArchivo) = "" And Timer - t < 5
DoEvents
Loop
If Dir(rutaArchivo) = "" Then
MsgBox "ERROR: El archivo no se generó: " & rutaArchivo, vbCritical
Exit Sub
End If
'--- ENVIAR MAIL ---
With Email
.To = correo_destino
.From = correo_origen
.Subject = Asunto
.TextBody = Mensaje
.Configuration.Fields.Update
.AddAttachment rutaArchivo
On Error Resume Next
.Send
End With
End Sub
Sub powerbuttonINQ()
Dim Izq As Single, Arr As Single, Ancho As Single, Alto As Single
Dim rutaArchivo As String
Dim Email As CDO.Message
Dim t As Single
Application.DisplayAlerts = False
Application.ScreenUpdating = False
ActiveSheet.Unprotect "4324"
'--- GENERAR IMAGEN DEL RECIBO ---
With Range("H7:R33")
Izq = .Left: Arr = .Top: Ancho = .Width: Alto = .Height
.CopyPicture
End With
With ActiveSheet.ChartObjects.Add(Izq, Arr, Ancho, Alto)
.Activate
.Chart.Paste
rutaArchivo = "C:\Users\Usuario\Google Drive\LOCACIONES\REC. INQUILINOS\" & _
Format(Range("Q20"), "mmmYY") & " - " & _
Range("Q9") & " - " & _
Range("P17") & " - " & _
Range("J17") & ".JPG"
.Chart.Export rutaArchivo
.Delete
End With
Range("AK30").Value = rutaArchivo
Range("AH6").Copy
Range("AH9").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Range("Y7:AI33").Copy
Range("H7").PasteSpecial xlPasteAll
ActiveSheet.Protect "4324"
ActiveWorkbook.Save
'--- EMAIL CONFIG ---
Set Email = New CDO.Message
correo_origen = "nqn.negocios@gmail.com"
Clave_correo_origen = "wkfhaapcnjljbwju"
correo_destino = Range("AK27").Value
Asunto = Range("AK28")
Mensaje = Range("AK29")
Email.Configuration.Fields(cdoSMTPServer) = "smtp.gmail.com"
Email.Configuration.Fields(cdoSendUsingMethod) = 2
With Email.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = correo_origen
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Clave_correo_origen
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
End With
'--- VERIFICAR ARCHIVO ---
t = Timer
Do While Dir(rutaArchivo) = "" And Timer - t < 5
DoEvents
Loop
If Dir(rutaArchivo) = "" Then
MsgBox "ERROR: El archivo no se generó: " & rutaArchivo, vbCritical
Exit Sub
End If
'--- ENVIAR ---
With Email
.To = correo_destino
.From = correo_origen
.Subject = Asunto
.TextBody = Mensaje
.Configuration.Fields.Update
.AddAttachment rutaArchivo
On Error Resume Next
.Send
End With
End Sub
Por
JSDJSD, · publicado
Buenos Días Foro;
La presente tiene para resolver las siguientes dudas respecto a códigos en SQL
teniendo la siguiente información me piden desarrollar las siguientes preguntas:
Empleando la BD INFRANCIONES. Coloque el código SQL para las siguientes consultas:
1. Seleccione los nombres y apellidos de propietarios que tienen más de un vehículo.
2. Seleccione todos los campos de aquellas papeletas que se han impuesto en la segunda quincena del mes de Marzo del 2006.
3. Seleccione las placas de vehículos, la descripción de su color y marca, así como su multa acumulada por todas las papeletas impuestas.
4. Seleccione el código y descripción de las infracciones que no han generado papeletas.
5. Seleccione las descripciones de marcas y la cantidad de vehículos por cada marca.
Luego de las preguntas planteadas empiezo a desarrollar los códigos según mi criterio
pero hay 1 pregunta que no puedo resolver, y quiero saber si las preguntas que he resuelto
están bien desarrolladas .....
Desarrollando los códigos SQL para las siguientes consultas:
1. Seleccione los nombres y apellidos de propietarios que tienen más de un vehículo.
SELECT NOM_PROPIETARIO, APE_PROPIETARIO, COUNT(NUM_PLACA)
FROM TB_PROPIETARIO P INNER JOIN TB_AUTO A ON P.COD_PROPIETARIO=A.COD_PROPIETARIO GROUP BY NOM_PROPIETARIO, APE_PROPIETARIO HAVING COUNT (NUM_PLACA)>1
2. Seleccione todos los campos de aquellas papeletas que se han impuesto en la segunda quincena del mes de Marzo del 2006
SELECT NUM_PAPELETA, FEC_PAPELETA, COD_INFRACCION, NUM_PLACA, EST_PAPELETA, COD_AGENTE
FROM TB_PAPELETA
WHERE FEC_PAPELETA BETWEEN 2006-03-16 AND 2006-03-31
3. Seleccione las placas de vehículos, la descripción de su color y marca, así como su multa acumulada por todas las papeletas impuestas
SELECT NUM_PLACA, DES_COLOR, DES_MARCA, SUM(MULTA)
FROM TB_AUTO, TB_COLOR, TB_INFRACCION, TB_MARCA
WHERE TB_COLOR.COD_COLOR = TB_AUTO.COD_COLOR AND TB_MARCA.COD_MARCA = TB_AUTO.COD_MARCA
GROUP BY NUM_PLACA, DES_COLOR, DES_MARCA
4. Seleccione el código y descripción de las infracciones que no han generado papeletas.
5. Seleccione las descripciones de marcas y la cantidad de vehículos por cada marca.
SELECT DES_MARCA, COUNT(NUM_PLACA)
FROM TB_AUTO A INNER JOIN TB_MARCA M ON
A.COD_MARCA=M.COD_MARCA
GROUP BY DES_MARCA
Infracciones.rar