Macro diferentes formatos de fotos

Es un gusto saludarlos.

Tengo la siguiente macro que pega fotos en jpg y jpeng desde una carpeta externa.
La macro funciona perfecto. Mi consulta es si es posible extender esta macro a más tipos de formatos de fotos: gif; bmp; png; etc.

Muchas gracias.

Sub im4()
'Por.Dante Amor
    ruta = "C:\trabajo\varios\"
    For i = 2 To Range("B" & Rows.Count).End(xlUp).Row
        arch = Dir(ruta & Cells(i, "B") & ".jp*")
        If arch <> "" Then
            With Cells(i, "A")
                Arriba = .Top + 1
                Izquierda = .Left + 1
                Ancho = .Width - 2
                Alto = .Height - 2
            End With
            '
            Set fotografia = ActiveSheet.Pictures.Insert(ruta & arch)
            With fotografia
                .Placement = xlMoveAndSize
                .ShapeRange.LockAspectRatio = msoFalse
                .Top = Arriba
                .Left = Izquierda
                .Width = Ancho
                .Height = Alto
            End With
            Set fotografia = Nothing
        End If
    Next
End Sub

1 respuesta

Respuesta
1

Cambia esta línea:

arch = Dir(ruta & Cells(i, "B") & ".jp*")

por esta:

arch = Dir(ruta & Cells(i, "B") & ".*")

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas