Como añadir una imagen a una macro

Sub GuardarHoja()
'Por.Dante Amor
    Application.ScreenUpdating = False
    Set l1 = ThisWorkbook
    Set h1 = l1.Sheets("factura") 'Nombre de la Hoja a guardar
    Set l2 = Workbooks.Add
    Set h2 = l2.Sheets(1)
    ruta = "C:\Trabajo\"          'Ruta
    factura = h1.[D8]             'Celda con el número de factura
    fecha = Format(Date, "dd-mmm-yyyy")
    '
    h1.Cells.Copy
    h2.Range("A1").PasteSpecial Paste:=xlPasteValues
    h2.Range("A1").PasteSpecial Paste:=xlPasteFormats
    h2.Range("A1").PasteSpecial Paste:=xlPasteColumnWidths
    l2.SaveAs ruta & factura & fecha & ".xlsx"
    l2.Close False
    MsgBox "Factura guardada", vbInformation
End Sub

hola tengo esta macro y en esta hoja he añadido una logotipo después de tener la macro  llamada imagen 1(a1-a4) que tendría que hacer para cuando ejecute la macro se guarde con el logo 

1 Respuesta

Respuesta
1

 H o  l a:

Te anexo la macro actualizada:

Sub GuardarHoja()
'Por.Dante Amor
    Application.ScreenUpdating = False
    Set l1 = ThisWorkbook
    Set h1 = l1.Sheets("factura") 'Nombre de la Hoja a guardar
    Set l2 = Workbooks.Add
    Set h2 = l2.Sheets(1)
    ruta = "C:\Trabajo\"          'Ruta
    factura = h1.[D8]             'Celda con el número de factura
    fecha = Format(Date, "dd-mmm-yyyy")
    '
    h1.Cells.Copy
    h2.Range("A1").PasteSpecial Paste:=xlPasteValues
    h2.Range("A1").PasteSpecial Paste:=xlPasteFormats
    h2.Range("A1").PasteSpecial Paste:=xlPasteColumnWidths
    h1.DrawingObjects("1 imagen").Copy
    h2.Paste
    Selection.Top = Range("A1").Top
    Selection.Left = Range("A1").Left
    l2.SaveAs ruta & factura & fecha & ".xlsx"
    l2.Close False
    MsgBox "Factura guardada", vbInformation
End Sub

Cambia en esta línea:

H1. DrawingObjects("1 imagen"). Copy
El nombre de la imagen, yo puse "1 imagen", pero si estás seguro que es "imagen 1" entonces cambia el dato.


Añade tu respuesta

Haz clic para o

Más respuestas relacionadas