Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, August 29, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Clipboard Usage
Robert Levine
Posts: 132
 
Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 May 07 11:08 AM
Is there a way in VBA to copy a string to the Windows Clipboard. I see functions to clear and read the Clipboard, but I don't see any method for writing to the Clipboard.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 May 07 11:16 AM
Yeah, it's a real bummer that Sage didn't add in methods to copy to the clipboard when they added those to read from the clipboard. The problem is that there's no built-in ways in VBScript to access clipboard. However, a quick trick might work for you. If you are able to place a hidden textbox or memo control on a form, you can add your text to that and then use it's CopyToClipboard method.

ie:

' copy some text to the clipboard
Edit1.Text = "Copy this text to the clipboard." & vbCrLf & "Goodbye and thanks for all the fish!"
Edit1.CopyToClipboard
' my text is now on the clipboard


Make sense?
[Reply][Quote]
Robert Levine
Posts: 132
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 May 07 1:39 PM
fiogf49gjkf0d
Ryan,
Thanks for getting back to me quickly. I tried the 'CopyToClipboard' method and can report that it does not work. Maybe I'm doing something wrong, but nothing shows up in the clipboard. I even tried a few combinations of things without any luck. The instructions appear to run, but produce zero results.
At least thanks for trying to help,
Bob
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 May 07 1:43 PM
fiogf49gjkf0d
It's been a while since I used that, but I have used that before and it worked fine for me. One thing I can't remember, is if CopyToClipboard copies the selected text or all text. If it copies only the selected text then you'd add a call to SelectAll:

' copy some text to the clipboard
Edit1.Text = "Copy this text to the clipboard." & vbCrLf & "Goodbye and thanks for all the fish!"
Edit1.SelectAll
Edit1.CopyToClipboard
' my text is now on the clipboard


Give that a try.
[Reply][Quote]
Robert Levine
Posts: 132
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 May 07 2:03 PM
fiogf49gjkf0d
YES! That's the answer. I never thought to use that combination. But it works like a charm. I even added a 'Application.clipboard.clear' before the '.selectall' to make sure that only the intended text is copied.
Much thanks,
Regards,
Bob
[Reply][Quote]
Guy Barrett
Posts: 63
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 4:17 AM
I might be being a bit dumb here, but how does this work if you are working from within an independent script that is not attached to a form? Is there any way of declaring a textbox as an object using script?

Thank you!
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 5:35 AM
Accessing the clipboard through VBS is actually a PITA and it does not appear to be possible directly.

Here is a way that may work for you, depending on your IE security settings:

set ie=createobject("internetExplorer.application")
ie.navigate "about:blank"
do until ie.readystate=4: wscript.sleep 1: loop
ie.document.parentwindow.clipboardData.setData "Text", "test"


Adding about:blank to the list of Trusted sites in IE should make any error/warning prompts go away.

Phil
[Reply][Quote]
Guy Barrett
Posts: 63
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 8:53 AM
That was just crazy enough to work.

I didn't realise you could grab hold of IE for that purpose. It gives a "application it trying to use the clipboard" confirmation dialog that I have to agree to first, but for the sake of testing code (such as copying failed SQL statements to the clipboard), it is ideal!

Thank you!
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 9:07 AM
Don't need to do that, you could use the Application.Clipboard functions. AsText is a Read/Write Property. See my sample code below (I have used it many times and just verified in 7.5 before replying):

'Clear the Clipboard:
Application.Clipboard.Clear

'Set the Clipboard:
Application.Clipboard.AsText = "This is the text I want on the Clipboard"

'Read the Clipboard:
msgbox Application.Clipboard.AsText
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 9:09 AM
Quote:
Originally posted by Robert Levine

Is there a way in VBA to copy a string to the Windows Clipboard. I see functions to clear and read the Clipboard, but I don't see any method for writing to the Clipboard.


The AsText is not a function, but rather a Read/Write Property, you could use it to Read and Write to the Clipboard.
[Reply][Quote]
Guy Barrett
Posts: 63
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 9:22 AM
Aha!

When I was reading the Saleslogix Developers Ref, it is worded as though it was Read Only so I didn't bother trying. However, you're right, I just tried it and it worked! That's twice in one day Raul. I'm posting another in a minute, see if you can make it a hat trick

Application.Clipboard
AsText
Exposed In Version 6.2
Function Returns the current contents of the Windows clipboard.
Object Application.Clipboard.AsText
Syntax AsText( = Value)
Parameters None
Returns String - the current contents of the clipboard.
Related Topics N/A
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Clipboard UsageYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Aug 09 9:59 AM
We are using SLX 6.1000 around here for one customer so we still don't have the application.clipboard stuff....

As suggested, we use IE for the clipboard and it does quite nicely.

One caveat, the user's internet explorer security options for the internet must Enable or Prompt for Scripts: Allow Programmatic clipboard access. If it's disabled you'll get some bad results.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 8/29/2025 12:30:06 PM