vba VBA复制按钮从文本框中复制文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6185282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 13:20:59  来源:igfitidea点击:

VBA copy button to copy text from textbox

excelvbaexcel-vba

提问by Sérgio Louren?o

I need to create a copy button to copy the text i previously inserted in a textbox, all this in excell

我需要创建一个复制按钮来复制我之前在文本框中插入的文本,所有这些都在 Excel 中

回答by Oneide

Consider you have a TextBox named TextBox1and a CommandButton named CommandButton1:

假设您有一个名为 TextBoxTextBox1和一个名为 的 CommandButton CommandButton1

Private Sub CommandButton1_Click()
    Dim MyData As New DataObject
    MyData.SetText TextBox1.Text
    MyData.PutInClipboard
End Sub

After clicking CommandButton1, the text on TextBox1 is ready to be pasted in any proper place.

单击 CommandButton1 后,TextBox1 上的文本已准备好粘贴到任何适当的位置。