Share via


Button.CopyPicture Method

Copies the Button to the Clipboard as a picture.

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

Syntax

'Declaration
Public Function CopyPicture ( _
    Appearance As XlPictureAppearance, _
    Format As XlCopyPictureFormat _
) As Object
public Object CopyPicture(
    XlPictureAppearance Appearance,
    XlCopyPictureFormat Format
)

Parameters

  • Appearance
    Type: XlPictureAppearance

    Specifies how the picture should be copied.

  • Format
    Type: XlCopyPictureFormat

    The format of the picture. Accepts the value xlPicture.

Return Value

Type: System.Object
true if the copy is successful; otherwise, false.

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Examples

The following code example demonstrates a Button control that copies itself to the Clipboard when the user clicks it. The Click event handler of the button calls the CopyPicture method to copy the button to the Clipboard as a bitmap.

This example is for a document-level customization.

Private Sub CopyControlAsPicture()
    Dim CopyButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B2", "D3"), "CopyButton")

    CopyButton.Text = "Click to copy this control" 
    AddHandler CopyButton.Click, AddressOf copyButtonPicture_Click
End Sub 


Private Sub CopyButtonPicture_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim ClickedButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        CType(sender, Microsoft.Office.Tools.Excel.Controls.Button)

    ClickedButton.CopyPicture(Excel.XlPictureAppearance.xlScreen, _
        Excel.XlCopyPictureFormat.xlBitmap)

End Sub
private void CopyControlAsPicture()
{
    Microsoft.Office.Tools.Excel.Controls.Button copyButton =
        this.Controls.AddButton(this.Range["B2", "D3"],
        "copyButton");

    copyButton.Text = "Click to copy this control";
    copyButton.Click += new EventHandler(copyButtonPicture_Click);
}

void copyButtonPicture_Click(object sender, EventArgs e)
{
    Microsoft.Office.Tools.Excel.Controls.Button clickedButton =
        (Microsoft.Office.Tools.Excel.Controls.Button)sender;

    clickedButton.CopyPicture(
        Excel.XlPictureAppearance.xlScreen,
        Excel.XlCopyPictureFormat.xlBitmap);
}

.NET Framework Security

See Also

Reference

Button Class

Microsoft.Office.Tools.Excel.Controls Namespace