473,394 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

put text in Office Clipboard

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.
Jul 23 '05 #1
2 5464
"Coder" <im************@gmail.com> wrote in message
news:7e**************************@posting.google.c 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.--
Jul 23 '05 #2
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
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: William Gill | last post by:
Is there a simple way to cut and paste from a tkinter text widget to an entry widget? I know I could create a mouse button event that triggers a popup (message widget) prompting for cut/paste in...
12
by: BC | last post by:
Hello, We are creating an Office add-in. We are able to display the add-in successfully. However, we followed a sample program, and it displays a FaceID = 1044 (which is not the bitmap of the...
2
by: David Dvali | last post by:
How can I cut/copy/paste text from/into textbox using clipboard from my code?
1
by: dananrg | last post by:
Can you tell I miss Unix? I want to write a Python script that, when launched, will choose a random .sig (from a list of about 30 cool ones I've devised), and store the .sig text in the Windows...
2
by: Andy_Khosravi | last post by:
I have a form with a large memo field that is designed to hold lengthy comments. There are times when my users need to paste in e-mails directly into the comment box. This works fine unless their...
22
by: JJ | last post by:
Whats the best way for me to pull out records from a tab delimited text file? Or rather HOW do I parse the text, knowing that the tabs are field delimiters and a return (I image) signifies a new...
5
by: countryboy | last post by:
I managed to get my text to the clipboard now I am trying to figure out how to compare it two different options. i know the goto is not good but I'm not sure a different way to do it. If...
8
by: Irene | last post by:
Hi, I have an MS Access Database with 1 Table containing about 2 million records in Unicode (diferent languages). I would like to export the Table to a Text file (CSV, Tab, etc.) Access...
8
by: kroogar | last post by:
Hi gurus .Net 2.0 I'm on a project where I need to be able to detect if my clipboard contains BOTH images AND text (eg. when copying from a web page). For some reason...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.