Condividi tramite


Button.CopyPicture(XlPictureAppearance, XlCopyPictureFormat) Method

Definition

Copies the Button to the Clipboard as a picture.

public:
 System::Object ^ CopyPicture(Microsoft::Office::Interop::Excel::XlPictureAppearance Appearance, Microsoft::Office::Interop::Excel::XlCopyPictureFormat Format);
public object CopyPicture (Microsoft.Office.Interop.Excel.XlPictureAppearance Appearance, Microsoft.Office.Interop.Excel.XlCopyPictureFormat Format);
member this.CopyPicture : Microsoft.Office.Interop.Excel.XlPictureAppearance * Microsoft.Office.Interop.Excel.XlCopyPictureFormat -> obj
Public Function CopyPicture (Appearance As XlPictureAppearance, Format As XlCopyPictureFormat) As Object

Parameters

Appearance
XlPictureAppearance

Specifies how the picture should be copied.

Format
XlCopyPictureFormat

The format of the picture. Accepts the value xlPicture.

Returns

true if the copy is successful; otherwise, false.

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 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);
}
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

Remarks

Optional Parameters

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

Applies to