Monday, April 30, 2012

How to copy content to Clipboard

We can use clipboard using two ways.
One is using Mercury.Clipboard.
Second one is using DotNetFactory.


Using Mercury.Clipboard:
'Creates an instance of Mercury.Clipboard
set objCB=createobject("Mercury.Clipboard")
'Here i am clearing already existing content in clipboard
objCB.Clear()
'Copying some text into Clipboard
objCB.SetText("Hello Uday")
'Retrieving the content from Clipboard
print objCB.GetText

Using DotNetFactory:
'Creates an instance of DotNetFactory Computer Object
Set objDFComputer=DotNetFactory("Microsoft.VisualBasic.Devices.Computer","Microsoft.VisualBasic")
'Here i am clearing already existing content in clipboard
Set objCB=objDFComputer.ClipBoard
objCB.clear()
'Copying some text into Clipboard
objCB.SetText("Hello Uday")
'Retrieving the content from Clipboard
print objCB.GetText

1 comment:

automationtester said...

hi its a helpful post

when I try to copy more than 10 lines of text to clipboard using settext and then when i try to gettext the code does not retrieve text.

have you noticed any limitation on the text size?