• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

VB Script Control Object

I'm making a small 'macro' type program and when the user runs their macro it converts the macro text into VB script.. eg :

MessageBox 'Hello' in my macro text gets converted to
MsgBox "Hello"

Im using The Microsoft Script Control To Do This. I've come across one problem though..

When trying to gain access to the clipboard controls (clipboard.settext & clipboard.gettext) And im getting a runtime error 424.. Object required 'Clipboard' So :

SetClipboard 'Text!' is converted to
Clipboard.SetText "Text!" fine, i checked the string, but its not working!! :(

Any Ideas?
  • 2
1 Solution
VBScript doesn't support the Clipboard object.

If you need to access the clipboard from your script, you're going to need to do some more work:

   * Create a new project (Utility), add a class (Clipboard), and give it methods that delegate to VB's clipboard.
   * Compile the (Utility) project.
   * Convert the macro as follows:

   Before:  SetClipboard 'Text!'
   After:   CreateObject("Utility.Clipboard").SetText "Text!"
get the user to type the macro text into a text box then you can do clipboard.settext textbox.text
dgc_lexxAuthor Commented:
I need a solution that preferably doesnt use any external files, as the macro program has the ability to compile into a single Executable that the users can distribute. Is there a way i could do it using API?
There are API functions for doing this, but they aren't accessible via VBScript either, so you'll still have to write a wrapper in VB.  Given that this is the case, there is no reason to prefer the API over VB's built-in support with the Clipboard object.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now