共用方式為


Button.CopyPicture 方法

Button 以圖片形式複製到剪貼簿中。

命名空間:  Microsoft.Office.Tools.Excel.Controls
組件:  Microsoft.Office.Tools.Excel.v4.0.Utilities (在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

語法

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

參數

傳回值

型別:System.Object
如果複製成功,則為 true,否則為 false。

備註

選擇性參數

如需選擇性參數的詳細資訊,請參閱Office 方案中的選擇性參數

範例

下列程式碼範例示範 Button 控制項在由使用者按下時,會自行複製至 [剪貼簿]。 這個按鈕的 Click 事件處理常式會呼叫 CopyPicture 方法,將按鈕以點陣圖複製到 [剪貼簿] 中。

這是示範文件層級自訂的範例。

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 安全性

請參閱

參考

Button 類別

Microsoft.Office.Tools.Excel.Controls 命名空間