Solved

VBScript: getting text from clipboard - is it possible?

Posted on 2004-08-08
3
6,330 Views
Last Modified: 2012-06-14
is it possible to get text from clipboard in VBScript? i have tried the following but it does not work:

Dim MyDataObj As New DataObject
MyDataObj.GetFromClipboard
Dim MyVar As Variant
MyVar = MyDataObj.GetText()
MsgBox MyVar

p.s. i want to implement this in stand-alone *.vbs script file, not in html file
0
Comment
Question by:latsubs
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
DarkoLord earned 50 total points
ID: 11747112
I don't think there is a 'native' function in VBScript to access clipboard... however, there is a workaround using IE to access clipboard (credits go  to "Christoph Basedau"):

msgbox ReadClipboard

function ReadClipboard
 ' Reads Clipboard into a variable
 ' by Christoph Basedau
 with createobject("internetexplorer.application")
  .navigate "about:blank"
  ReadClipboard = _
   .document.parentwindow.clipboardData.getData ("text")
  .quit
 end with
end function

Darko
0
 

Author Comment

by:latsubs
ID: 11748783
maybe there is also some way (workaround) to use SendKeys() function within VBScript?

p.s. of course, i will give you points...
0
 

Author Comment

by:latsubs
ID: 11751751
forget it, i figured out it myself...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question