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
Sub Copiarypegar()
Application.ScreenUpdating = False
'Range("Q1:EF1").Locked = False
'Seleccionamos todo el área contínua de datos, desde la celda donde estamos situados
Range("a12:A30").Select 'seleciona el rango especifico
'ActiveCell.CurrentRegion.Select
'Copiamos
Selection.Copy
'Pegamos en A12 de la hoja 2
Sheets("DAILY REPORT").Select
Range("A12").Select 'el control se hará sobre la columna A, a partir de la fila
While ActiveCell.Value <> "" 'Busca la ultima fila
ActiveCell.Offset(1, 0).Select 'si la celda contiene datos, pasa a la fila siguiente
Wend
ActiveSheet.PasteSpecial
Application.CutCopyMode = False
'Hoja1.Rows(12).ClearContents
Hoja1.Range("a14").ClearContents
Hoja1.Range("b14").ClearContents
Hoja1.Range("c14").ClearContents
Hoja1.Range("d14").ClearContents
Hoja1.Range("e14").ClearContents
Hoja1.Range("f14").ClearContents
Hoja1.Range("g14").ClearContents
Hoja1.Range("h14").ClearContents
Hoja1.Range("i14").ClearContents
Hoja1.Range("a17").ClearContents
Hoja1.Range("b17").ClearContents
Hoja1.Range("c17").ClearContents
Hoja1.Range("d17").ClearContents
Hoja1.Range("e17").ClearContents
Hoja1.Range("g17").ClearContents
Hoja1.Range("h17").ClearContents
Hoja1.Range("i17").ClearContents
Hoja1.Range("a20").ClearContents
Hoja1.Range("b20").ClearContents
Hoja1.Range("c20").ClearContents
Hoja1.Range("d20").ClearContents
Hoja1.Range("e20").ClearContents
Hoja1.Range("f20").ClearContents
Hoja1.Range("g20").ClearContents
Hoja1.Range("h20").ClearContents
Hoja1.Range("i20").ClearContents
Hoja1.Range("a23:c23").ClearContents
Hoja1.Range("d23:f23").ClearContents
Hoja1.Range("g23").ClearContents
Hoja1.Range("h23").ClearContents
Hoja1.Range("i23:j23").ClearContents
Hoja1.Range("a26:c26").ClearContents
Hoja1.Range("a29:i29").ClearContents
Range("a14").Select
'Range("Q1:EF1").Locked = True
MsgBox ("DATOS GUARDADOS EXITOSAMENTE
")
Application.ScreenUpdating = True
End Sub
el tema que la celda a29 en la hoja1
tiene este codigo.
Sub celda_29()
Application.ScreenUpdating = False
Sheets("VUELO").Select
Range("A29").Select
Selection.UnMerge
Selection.EntireRow.AutoFit
Selection.Merge
Application.ScreenUpdating = True
End Sub
al copiar todo a la hoja dos el formato no lo respeta.
esta celda se repite cada 13 filas.
Me podrian hechar una mano