Q:
Hi, scripting guy! Is there a way to copy the Script output to the clipboard?
-- ZW, Marseilles, France
A:
Hello ZW. If you don't mind using some crazy solutions, it is quite easy to copy the Script output to the clipboard. First, you need to construct a string containing the desired output. Create an Internet Explorer instance and open a blank page. Next, use the built-in functions of the Internet Explorer Object Model to copy strings to the clipboard. In particular, you can use the clipboardData. setdata method to implement this technique. The following is an example script for copying data to the clipboard:
CopyCodeThe Code is as follows: strcopy = "this text has been copied to the clipboard ."
Set objie = Createobject ("internetexplorer. application ")
Objie. navigate ("about: blank ")
Objie.doc ument. parentwindow. clipboardData. setdata "text", strcopy
Objie. Quit
Run the script, open notepad, and click paste. The copied string is displayed.
By the way, all this is happening behind the scenes, and Internet Explorer does not actually appear on the screen. This is because, by default, any ie instance created using the script is hidden at runtime, unless you use the following statement to display it:
Objie. Visible = true
For more information about clipboardData. setdata, see the DHTML reference document on msdn.