CAMBIar nombre de pdf generado de una hoja excel
Tengo este codigo que me funciona muy bien, el detalle esta que cuando la ejecuto se genera el pdf agarrando el nombre de la hoja en este caso "COTIZACION" hay alguna manera de que agarre el nombre del pdf basado en una celda? Gracias dan saludos
Sub CorreoPDF()
'On Error GoTo ENVIO
If Range("F11") = "" Then
MsgBox "No hay correo Disponible", vbCritical, "ERROR"
Exit Sub
End If
If Range("L42") = 0 Then
MsgBox "No hay productos seleccionados", vbExclamation, "ERROR"
Exit Sub
End If
If Range("O3").Value = "SI" Then
MsgBox "COTIZACIÓN CON DESGLOCE DE *IMPUESTOS*", vbInformation, "IVA 16% - IEPS 8%"
Else
MsgBox "COTIZACIÓN CON PRECIO DE VENTA", vbInformation, "SIN IMPUESTOS INCLUIDOS"
End If
If Range("O1").Value = "" Then
MsgBox "SIN SUCURSAL CERCANA...", , "AVISO"
Else
MsgBox "SUCURSAL CERCANA: " & Sheets("COTIZACION").Range("O1").Value, , "AVISO"
End If
ActiveSheet.Unprotect
GOMART = MsgBox("¿Enviar Cotización?" & " al correo: " & Range("f11") & " de " & Range("f9"), vbQuestion + vbYesNo, "OUTLOOK")
If GOMART = vbYes Then
'por.Dante Amor
'Enviar una hoja por correo
ActiveSheet.Unprotect
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'
Set h2 = ActiveSheet
wpath = ThisWorkbook.Path & "\"
nombre = h2.Name
nombree = h2.[B10]
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=wpath & nombre & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Set l1 = ThisWorkbook
Set h1 = Sheets("COTIZACION")
CEL = h1.[BQ3]
CEL2 = h1.[BO3]
CEL3 = h1.[CA1]
ruta = l1.Path & "\"
Set l2 = Workbooks.Add
Set h2 = l2.Sheets(1)
h1.Range("E2:L48").Copy
h2.[A1].PasteSpecial Paste:=xlValues
h2.[A1].PasteSpecial Paste:=xlPasteFormats
l2.SaveAs Filename:=ruta & h1.Name & ".xlsx", FileFormat:=xlOpenXMLWorkbook
l2.Close
'
Set dam = CreateObject("outlook.application").createitem(OLMAILITEM) '
dam.To = h1.Range("F11") ''"[email protected]" '"[email protected]" 'Destinatarios"[email protected]"
dam.CC = h1.Range("T3")
dam.BCC = h1.Range("T5")
dam.Subject = "Nota de Cotización de Panificadora el RETORNO" 'h1.Range("K2") & " DE: PANIFICADORA EL RETORNO" ''"ANOMALIAS DE VENTAS, MATRIZ: " & CEL2 & " DEL MES DE: " & CEL '"Asunto"
dam.Body = h1.Range("T7") ''" Este Reporte fue enviado el dia " & CEL3 & " Confirmar de Recibido Porfavor, SALUDOS!!!" '"Cuerpo del mensaje"
'dam.Attachments.Add ruta & h1.Name & ".xlsx"
dam.Attachments.Add wpath & nombre & ".pdf"
Dam. Send
'MsgBox "ADJUNTA las facturas de " & Sheets("COTIZACION"). Range("A1").Value & " Antes de enviar el correo", vbInformation, "COTIZACION"
'IraCarpeta
' Dam. Send
'dam. Display
ActiveSheet. Unprotect
Sheets("COTIZACION").Range("L3").Value = Sheets("COTIZACION").Range("L3").Value + 1
ActiveSheet. Protect
Limpieza
' ActiveSheet. Protect
MsgBox "Correo enviado y guardado", vbInformation, "GOMART"
DoEvents
Kill wpath & nombre & ".pdf"
Kill wpath & h1.Name & ".xlsx"
DoEvents
'ENVIO:
' MsgBox "Los datos del destinatario no son correctos!, corrigelos para continuar", vbExclamation, "POSIBLE ERROR"
End If
End Subme puedes ayudar en esta otra pregunta??? :C
Conversión de una macro ejecutable en cambio de dato en hoja
1 respuesta
Respuesta de Dante Amor
1