xlf | xlfAddLogoToBanner

Add a logo image to the worksheet

Add the xlf logo image to a worksheet (figure 1), similar to the logo on this web page.

  1. xlf-blue-banner
    Fig 1: the xlf logo image applied to a worksheet

xlfAddLogoToBanner - the VBA code

In this example, the picture image file is located on a web server. Code 1 uses the mso AddPicture method. The image location and size is measured in points, where 1 point is equal to 1/72 of an inch.

Code 1: Sub procedure xlfAddLogoToBanner add xlf logo to a selected area of worksheet
Private Sub xlfAddLogoToBanner()
Dim imgSource As String

    imgSource = "http://excelatfinance.com/online/wp-content/uploads/2015/06/xlf.png"
    ActiveSheet.Shapes.AddPicture imgSource, msoFalse, msoTrue, 13, 13, 35, 35

End Sub												

AddPicture method - Creates a picture from an existing file (local or remote / web). Returns a Shape object that represents the new picture.

Syntax: expression.AddPicture(Filename, LinkToFile, SaveWithDocument, Left, Top, Width, Height)

expression: ActiveSheet.Shapes
argument / parameterdetails
Filenamerequiredstring - the source of the picture file
LinkToFilerequiredMsoTriState [msoTrue / msoFalse] - make an independent copy of the file
SaveWithDocument requiredMsoTriState [msoTrue / msoFalse] - save the picture with the workbook
Leftrequiredsingle - distance from left of worksheet to the left of the picture in points
Toprequiredsingle - distance from top of worksheet to the top of the picture in points
Widthrequiredsingle - the width of the picture in points
Heightrequiredsingle - the height of the picture in points

Run the private procedure from the VBE. Use F5 or Run > Run Sub on the menu.