?
Solved

VB Script Control Object

Posted on 2003-03-14
4
Medium Priority
?
333 Views
Last Modified: 2013-11-26
Hey,
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?
0
Comment
Question by:dgc_lexx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
JMoon5FTM earned 405 total points
ID: 8138144
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!"
0
 
LVL 1

Expert Comment

by:hazgod
ID: 8140135
get the user to type the macro text into a text box then you can do clipboard.settext textbox.text
0
 

Author Comment

by:dgc_lexx
ID: 8140186
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?
0
 
LVL 5

Expert Comment

by:JMoon5FTM
ID: 8195357
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.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

764 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