Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > put text in Office Clipboard

Reply
Thread Tools

put text in Office Clipboard

 
 
Coder
Guest
Posts: n/a
 
      11-20-2004
Hi,

I wanted to know of a way that I can put text into the Office
(Outlook/Word) clipboard from Internet Explorer.

So when a user a user clicks on a button, some text is placed into the
clipboard.

Ive tried this, but no luck.

<script language="javascript">
function cpy(myString){
if((typeof window.clipboardData != 'undefined')&&
(window.clipboardData.setData)){
alert('setting: ' + myString);
res = window.clipboardData.clearData();//("text",myString);

alert(res);
}
else {
alert('null');
}
}
</script>

- Thanks.
 
Reply With Quote
 
 
 
 
Tammo
Guest
Posts: n/a
 
      11-20-2004
"Coder" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi,
>
> I wanted to know of a way that I can put text into the Office
> (Outlook/Word) clipboard from Internet Explorer.
>
> So when a user a user clicks on a button, some text is placed into the
> clipboard.
>
> Ive tried this, but no luck.
>
> <script language="javascript">
> function cpy(myString){
> if((typeof window.clipboardData != 'undefined')&&
> (window.clipboardData.setData)){
> alert('setting: ' + myString);
> res = window.clipboardData.clearData();//("text",myString);
>
> alert(res);
> }
> else {
> alert('null');
> }
> }
> </script>
>

You need a textarea or similar to temporarily hold your string.

// with <TEXTAREA ID="taCode" STYLE="display:none;"></TEXTAREA> in the body
// will copy the element with the given ID, or the selection if there is one
function copy2clipboard(t) {
taCode.innerText =
'\n'+(isselect()?isselect():document.getElementByI d(t).innerText);
textRange = taCode.createTextRange();
textRange.execCommand("RemoveFormat");
textRange.execCommand("Copy");
}
function isselect(){
if (document.getSelection) { return document.getSelection(); } // if IE4+
if (document.selection && document.selection.createRange) { return
document.selection.createRange().text; } // if NS
return false;
}
// to read the clipboard, use window.clipboardData.getData("Text");

http://4umi.com/web/javascript/

Hope this helps
Tammo.--


 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      11-20-2004
Coder wrote:
> Hi,
>
> I wanted to know of a way that I can put text into the Office
> (Outlook/Word) clipboard from Internet Explorer.
>
> So when a user a user clicks on a button, some text is placed into the
> clipboard.
>
> Ive tried this, but no luck.
>
> <script language="javascript">
> function cpy(myString){



if (window.clipboardData)
window.clipboardData.setData('text', myString)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clipboard - Copy Text To Clipboard Mahsha Javascript 3 06-01-2009 08:19 PM
$clipboard = Gtk::Clipboard.get('PRIMARY')... under windows Dan Bishop Ruby 0 08-26-2008 01:47 PM
clipboard.setContents destroys clipboard.getContents? spunibard@gmail.com Java 2 03-02-2007 07:52 PM
Paste from clipboard when clipboard changes mid script melvynm@gmail.com Javascript 4 12-14-2004 10:59 PM
Using VB.Net or C#, utilizing the clipboard object, how to copy an MS Excel graphic from the clipboard to an image control and obtain its source reference TC ASP .Net 5 09-01-2004 04:49 AM



Advertisments