MiyagiZama
New Member
- Joined
- Jul 26, 2023
- Messages
- 18
- Office Version
- 365
- Platform
- Windows
Hello mates!, hope you´re fine
I have a trouble with my excel macro due to Mail.Evelope doesn't have font size proprieties, and someone on the forum suggest me to put the message that I want to send in a cell and after that change the font size of these cell where I put the message but when I tried to run the macro for first time after turn on the pc, appears a pop up message which says "run time error 1004 size property of the font class", but after that I press in debug and run again the macro and it runs without trouble, this error only appears the first time after turn on my device, Could you help me with please c:
Here's the VBA code
I have a trouble with my excel macro due to Mail.Evelope doesn't have font size proprieties, and someone on the forum suggest me to put the message that I want to send in a cell and after that change the font size of these cell where I put the message but when I tried to run the macro for first time after turn on the pc, appears a pop up message which says "run time error 1004 size property of the font class", but after that I press in debug and run again the macro and it runs without trouble, this error only appears the first time after turn on my device, Could you help me with please c:
Here's the VBA code
VBA Code:
Sub BenditoCodigoJalaPOFAVO()
'
' Declaramos variables
'
Dim Asunto As String
Dim Correo As String
Dim Destinatario As String
Dim BOL As String
Dim FechaVencimiento As String
Dim Msg As String
Dim LastRow As Long
Dim Linea As String
'
'
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("A:A").Copy
Sheets("ReporteF").Activate
Cells(1, 1).Select
ActiveSheet.Paste
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("C:C").Copy
Sheets("ReporteF").Activate
Cells(1, 2).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("D:D").Copy
Sheets("ReporteF").Activate
Cells(1, 3).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("G:G").Copy
Sheets("ReporteF").Activate
Cells(1, 4).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("H:H").Copy
Sheets("ReporteF").Activate
Cells(1, 5).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("E:E").Copy
Sheets("ReporteF").Activate
Cells(1, 6).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("F:F").Copy
Sheets("ReporteF").Activate
Cells(1, 7).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("K:K").Copy
Sheets("ReporteF").Activate
Cells(1, 8).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("M:M").Copy
Sheets("ReporteF").Activate
Cells(1, 9).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("I:I").Copy
Sheets("ReporteF").Activate
Cells(1, 10).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("Q:Q").Copy
Sheets("ReporteF").Activate
Cells(1, 11).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("TablaCrudo").Activate
Sheets("TablaCrudo").Range("AB:AB").Copy
Sheets("ReporteF").Activate
Cells(1, 12).Select
ActiveSheet.Paste
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'AJUSTAMOS LAS CELDAS CON AUTOFIT Y LAS CENTRAMOS A LA CELDA
'
ActiveSheet.Columns("A:L").AutoFit
'
'EMPIEZA LA SEGUNDA MACRO
'
'
'DECLARAMOS EL RANGO QUE QUEREMOS COPIAR CON EL FOR
'
LastRow = ThisWorkbook.Sheets("ReporteF").Range("A1").CurrentRegion.Rows.Count
Sheets("ReporteF").Activate
Range("A:L").Select
'
'CENTRAMOS EL TEXTO DE LAS CELDAS
'
With Range("B:L")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
'
'
'Aumentar 10 filas
ActiveSheet.Rows("1:11").Insert
'
'
'LLAMAMOS AL ENVIO
'
'
ActiveWorkbook.EnvelopeVisible = True
'
'Asignamos valor a las variables y llamamos al envio
'
With ActiveSheet.MailEnvelope
BOL = Format(ThisWorkbook.Sheets("BOL").Range("B3").Value, "#,##0")
'ThisWorkbook.Sheets("BOL").Range("B3").Font.Bold = True
FechaVencimiento = Format(ThisWorkbook.Sheets("BOL").Range("C3").Value, "dd/mmm/yyyy")
'ThisWorkbook.Sheets("BOL").Range("C3").Font.Bold = True
Linea = Format(ThisWorkbook.Sheets("BOL").Range("J3").Value, "#,##0")
'
'
'ESCRIBIMOS NUESTRO MENSAJE EN LAS CELDAS QUE AÑADIMOS YA QUE EL MAIL ENVELOPE NO TIENE ATRIBUTOS PARA CAMBIAR TAMAÑO O COLOR DE FONT
'POSTERIORMENTE LE AUMENTAMOS EL TAMAÑO Y PONEMOS EN NEGRITAS EL TEXTO QUE DESEAMOS
'
Range("A1").Value = "Apreciables colegas, espero que se encuentren excelente el dia de hoy."
Range("A3").Value = "El motivo de este correo es para informarle que tiene material en BOL desde el: " & FechaVencimiento
Range("A5").Value = "Favor de apoyarnos con el plan para disminuir el numero de estas piezas: " & BOL
Range("A7").Value = "Atentamente:"
Range("A8").Value = "Departamento de programacion"
Range("A10").Value = "ESTO ES UNA PRUEBA FAVOR DE OMITIR"
Range("A1:A10").Font.Size = 16
Range("A10").Font.Bold = True
'
'
.Item.To = ThisWorkbook.Sheets("BOL").Range("F3").Value
'& ";" & ThisWorkbook.Sheets("ReporteFinal").Range("O4").Value & ";" & ThisWorkbook.Sheets("ReporteFinal").Range("O5").Value
'.Item.cc = ThisWorkbook.Sheets("ReporteFinal").Range("O7").Value
'.Item.bcc = "correo2@dominio.com" 'con copia oculta a...
.Item.Subject = "Programacion Linea: " & Linea
'.Introduction = "Apreciables colegas, espero que se encuentren excelente el dia de hoy. " & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "El motivo de este correo es para informarle que tiene material en BOL desde el: " & FechaVencimiento & "." & vbNewLine & vbNewLine & vbNewLine & vbNewLine & "Favor de apoyarnos con el plan para disminuir el numero de estas piezas: " & BOL & vbNewLine & vbNewLine & "Atentamente:" & vbNewLine & "Departamento de programacion" & vbNewLine & vbNewLine & vbNewLine & "ESTO ES UNA PRUEBA FAVOR DE OMITIR"
.Item.Send
'
'
End With
'
'BORRAR LAS FILAS QUE AÑADIMOS Y LAS COLUMNAS DE LA TABLA QUE ENVIAMOS POR CORREO
'
ActiveSheet.Columns("A:L").Delete
'
'
MsgBox "Se logrooooooo"
'
End Sub