WorksheetBase.SetBackgroundPicture Method

Sets the background graphic for the worksheet.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

'Declaration
Public Sub SetBackgroundPicture ( _
    filename As String _
)
public void SetBackgroundPicture(
    string filename
)

Parameters

Examples

The following code example uses the SetBackgroundPicture method to set the background image of the worksheet to a file named image1.jpg.

This example is for a document-level customization.

Private Sub SetWorksheetPicture()
    Dim backgroundFilePath As String = "C:\image1.jpg" 
    If System.IO.File.Exists(backgroundFilePath) Then 
        Me.SetBackgroundPicture("C:\image1.jpg")
    Else
        MsgBox("The file C:\image1.jpg does not exist.")
    End If 
End Sub
private void SetWorksheetPicture()
{
    string backgroundFilePath = @"C:\image1.jpg";

    if (System.IO.File.Exists(backgroundFilePath))
    {
        this.SetBackgroundPicture(@"C:\image1.jpg");
    }
    else
    {
        MessageBox.Show(@"The file C:\image1.jpg does not exist.");
    }
}

.NET Framework Security

See Also

Reference

WorksheetBase Class

Microsoft.Office.Tools.Excel Namespace