Página 1 de 1

[RESUELTO] BuscarV con imágenes

Publicado: Jue Nov 22, 2018 6:35 am
por mauricio
Usar imágenes con la función BuscarV, es un tema recurrente en este y otros foros. Usando Python es trivial.

Descarguen el archivo adjunto, asignen la siguiente macro al evento "Contenido cambiado", establezcan la ruta absoluta donde están las imágenes, usen el formato URL y listo.

Código: Seleccionar todo


PATH = 'file:///home/mau/Documents/img/{}.jpg'

def actualizar_imagen(source):
    if source.ImplementationName != 'ScCellObj':
        return

    cols = 0
    rows = 2
    sheet = source.Spreadsheet
    dp = sheet.DrawPage
    ca = source.CellAddress

    cell = sheet.getCellByPosition(ca.Column + cols, ca.Row + rows)
    img = False
    for i in dp:
        if cell.AbsoluteName == i.Anchor.AbsoluteName:
            img = i
            break

    if img:
        img.GraphicURL = PATH.format(cell.String)
        img.Visible = False
        img.Visible = True
    return
Por supuesto, pasar esto a Basic, también es trivial, pero Basic es muy aburrido. :lol:
buscar_imagen.gif