Nedenstående script bruger et (skjult) IE objekt med en lille HTML form til at få fat i clipboardet. Jeg gad ikke lave det så den midlertidige html-fil bliver slettet igen. Det må du selv fixe ;-)
Option Explicit
Dim oIE ' global object for IE
Dim txt ' handles clipboard text
Dim fso, f, sHTMLFileName, html
' Create Internet Explorer instance for clipboard access
MakeIEDoc
' Ask user for a text
txt = InputBox ("Enter a text", "Paste text to clipboard", "")
' write a text into text box
oIE.Document.All.exch.Value = txt
' Write text into IE document's text box ...
oIE.Document.All.exch.select()
' ... and transfer it to clipboard
oIE.Document.execCommand("Copy")
' Allow user to check the clipboard content
WScript.Echo "Written to clipboard: " & vbCRLF & txt & vbCRLF & _
vbCRLF & "Please check and alter the clipboard"
' read data from clipboard into text box ...
oIE.Document.execCommand("Paste")
' and show data obtained from this text box
WScript.Echo "Clipboard text:" & vbCRLF & oIE.Document.All.exch.Value
' close Internet Explorer instance
oIE.Quit
' clean up
Set oIE = Nothing
Sub MakeIEDoc ()
' Launch Internet Explorer & prepare a page with a text box
' define HTML code with a text area
html = "<html><head><title>Clipboard Exchange Helper</title></head>" & _
"<body bgcolor='silver'>" & _
"<textarea name='exch' rows='8' cols='80'></textarea>" & _
"</body></html>"
' write the HTML to a temporary file
sHTMLFileName = "1e74c834.html"
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile(sHTMLFileName)
f.Write(html)
f.Close
Set f= Nothing
Set fso = Nothing
sHTMLFileName = "
file:///" & Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\")) & sHTMLFileName
' *** launch Internet Explorer ***
Set oIE = WScript.CreateObject("InternetExplorer.Application")
oIE.left=50 ' window position
oIE.top = 100 ' and other properties
oIE.height = 200
oIE.width = 580
oIE.menubar = 0 ' no menu
oIE.toolbar = 0
oIE.statusbar = 0
oIE.navigate sHTMLFileName ' Helper window
oIE.visible = 0 ' keep invisible
Do While (oIE.Busy):Loop ' Important: wait till MSIE is ready
End Sub
'* End