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
VBA copy button to copy text from textbox
提问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 TextBox1
and 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 上的文本已准备好粘贴到任何适当的位置。