Copy the codeThe code is as follows:
Set IE = CreateObject("")
("about:blank")
Set clipboard =
'SetData sets the contents of the clipboard
"text", "Forgot, I like the feeling of being alone"
'GetData gets the contents of the clipboard
("text")
Practice has proved that searching a lot of code online is generally not good code. The SetData method is actually related to the settings of the IE browser.
The default setting of IE8 is Prompt, so a dialog box will pop up when running the above script. If this is Disable, then this script cannot set the clipboard content (the acquisition will not be affected).
It is better to use less code without guarantees. It can be used to set the contents of the clipboard under Windows 7. If you obtain it, just use IE.
Dim WshShell set WshShell = CreateObject("") str = "Forgot, I like the feeling of being alone" " /c echo " & str & " | clip",0,False
You can also set and get clipboard contents
'Set the contents of the clipboard Dim Word Set Word = CreateObject("") = "Forgot, I like the feeling of being alone" False
'Get the contents of the clipboard Dim Word Set Word = CreateObject("") (wdFormatPlainText) str = False str
The most amazing thing is to use Microsoft Forms 2.0 Object Library.
'Set the contents of the clipboard Dim Form, TextBox Set Form = CreateObject(".1") Set TextBox = Form.(".1").Object = True = "Forgot, I like the feeling of being alone" = 0 =
'Get the contents of the clipboard Dim Form, TextBox Set Form = CreateObject(".1") Set TextBox = Form.(".1").Object = True If Then End If
Reference link:
- [UMU WSH Tutorial](30) Access the clipboard
- [UMU WSH Tutorial](32) Access the clipboard (2)
Original text: /programming/