简体   繁体   English

如何使用 VBA 将文本复制到剪贴板?

[英]How to copy text to clipboard using VBA?

I need a bit help.. How to copy data automatically to the clipboard from the textbox?我需要一点帮助。如何将数据从文本框自动复制到剪贴板? This is a part of the programm, I already tried a few things..这是程序的一部分,我已经尝试了一些东西..

Sheets("Sheet1").Cells(sor, 1).Value = serial
Sheets("Sheet1").Cells(1, 2).Value = futo
UserForm1.TextBox1.Value = serial
ActiveWorkbook.Save
Application.AlertBeforeOverwriting = False

Dim MyData As DataObject

Set MyData = New DataObject
MyData.SetText UserForm1.TextBox1
MyData.PutInClipboard

End If

You are referencing the TextBox object, not the Text property of it.您引用的是 TextBox object,而不是它的 Text 属性。 Try this.尝试这个。

Sheets("Sheet1").Cells(sor, 1).Value = serial
Sheets("Sheet1").Cells(1, 2).Value = futo
UserForm1.TextBox1.Value = serial
ActiveWorkbook.Save
Application.AlertBeforeOverwriting = False

Dim MyData As New DataObject

MyData.SetText UserForm1.TextBox1.Text
MyData.PutInClipboard

End If万一

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM