Hello,

I am writing a macro that will dynamically insert any image with the word "logo" from the current directory. It is then inserted into the header of each page.

The code below works if the file is named logo.jpg, but I would like to add logic to include it if it is logo.png, logo.gif, logo.JPG etc.

Any tips?


Sub DSSHeaderImage()


Dim oSec As Section
Dim oHeader As HeaderFooter
Dim oLogo As InlineShape
Dim imgpath As String

    imgpath = ThisDocument.Path
    imgpath = imgpath & "\" & "logo.jpg"


    For Each oSec In ActiveDocument.Sections
        Set oHeader = oSec.Headers(wdHeaderFooterPrimary)
        With oHeader.Range
            .ParagraphFormat.Alignment = wdAlignParagraphRight
            Set oLogo = .InlineShapes.AddPicture(imgpath)
        End With
    Next oSec
End Sub
This question only posted here. Thank you