Micro Focus QTP (UFT) Forums
How to copy the content of a variable to clipboard - QTP 10 - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to copy the content of a variable to clipboard - QTP 10 (/Thread-How-to-copy-the-content-of-a-variable-to-clipboard-QTP-10)



How to copy the content of a variable to clipboard - QTP 10 - rohit330 - 02-21-2012

Hi All,

I am very new to QTP and is trying to automate some part of my testing.

I have some piece of code where am trying to copy one particular file (contents) to text area in my application.

Following is what i have achieved till now.

Code:
Function readTextFromFile(pathToFile)
   Set fso = createObject("Scripting.FileSystemObject")
   If fso.FileExists(pathToFile) = True Then
                   Set f = fso.OpenTextFile(pathToFile, 1)
                   readTextFromFile = f.ReadAll
                   f.Close
   End If
End Function
text = readTextFromFile("Path of file")

After this i wanted to copy the content of "text" to clipboard so that i can use pasting it to my app text area, which hopefully by the following code.

Code:
SwfWindow("MyApplication").SwfEditor("xmlTextBox").Type micCtrlDwn + "v" + micCtrlUp

Your advices will be much helpful for me to proceed.

Thanks in advance . .

Regards


RE: How to copy the content of a variable to clipboard - QTP 10 - inborntester - 02-22-2012

Code:
Set clipboard = createobject("mercury.clipboard")
clipboard.Clear
clipboard.SetText(text)



RE: How to copy the content of a variable to clipboard - QTP 10 - rohit330 - 02-22-2012

Thanks...Smile it worked Smile