Any RTF guru

G

galactic

Hello,

Does anyone know how to tell the cipboard to accept RTF into the
clipboard? I think I have all the steps but one.. has anyone done
this:

1. copied text into a separate area.
2. reformatted text into rtf format.
2. copied.holdtext.createTextRange();
3 . copied.execCommand("copy"); (only for ie)

but when I paste it still comes out as pure text.. not RTF... what am
I missing.

any help would be appreciated.

-Galactic
 
B

Bwig Zomberi

galactic said:
Hello,

Does anyone know how to tell the cipboard to accept RTF into the
clipboard? I think I have all the steps but one.. has anyone done
this:

1. copied text into a separate area.
2. reformatted text into rtf format.
2. copied.holdtext.createTextRange();
3 . copied.execCommand("copy"); (only for ie)

but when I paste it still comes out as pure text.. not RTF... what am
I missing.

any help would be appreciated.


Not sure what you mean by RTF format. However, a range object will
accept this method - execCommand("Copy"). For example, the following
external JS if called by IE will copy the selected page content as
rich text - same as pressing Ctrl+C.

var pwin = external.menuArguments;
var doc = pwin.document;
var sel = doc.selection;
var rng = sel.createRange();

rng.execCommand("Copy");

Open MS Word and do a Paste to check out the results.

From "Copy HTML Code" script of
http://www.vsubhash.com/article.asp?id=65&info=Context_Menu_Extensions_For_IE
 
G

galactic

Thank you BWig,

I just need to know if you know what format to place instead of "Text"

window.clipboardData.setData("Text", rng.htmlText);

I need it to show up in the clipboard as Rich Text only.

Thanks for any help
 
A

Antony Scriven

I just need to know if you know what format to place
instead of "Text"

window.clipboardData.setData("Text", rng.htmlText);

I need it to show up in the clipboard as Rich Text only.

Look up clipboardData on msdn. --Antony
 
B

Bwig Zomberi

galactic said:
Bwig,

Yes I believe the format is the Microsoft RTF - specifically I need to
be able to paste a ready made URL - complete with hidden A tag - into
Outlooks Signature box. The Outlook Signature interface (outlook
version 2003 11.8) will only accept a url as a Microsoft RTF Piece!
(Tools->Options->tabMailFormat->Signiatures.
It will not accept - say an "A" tag.. any HTML just get's copied as
"shown" HTML tags... but It will accept a Microsoft Document copied
URL from Excel or Word.. My business requirements are to be able to
leverage this type of copy straight from a web page...
I learned a little Rtf language, but need to tell the copy mechanism
this is the type of format I'm using...

If you copy a HTML-encoded or RTF-encoded hyperlink, it is still text.

In IE, it is possible to right-click a link and select the built-in
"Copy hyperlink" menu option. You could then paste the URL anywhere.
Does the Outlook Signature box not accept it? It should. I can't tell
for sure, as I do not have Outlook.

I do know that Outlook uses Word as the web page rendering engine but
something that has been copied to they Clipboard should be available for
paste operations anywhere. Just confirm the above does not work.
 
B

Bwig Zomberi

galactic said:
Bwig,

Yes I believe the format is the Microsoft RTF - specifically I need to
be able to paste a ready made URL - complete with hidden A tag - into
Outlooks Signature box. The Outlook Signature interface (outlook
version 2003 11.8) will only accept a url as a Microsoft RTF Piece!
(Tools->Options->tabMailFormat->Signiatures.
It will not accept - say an "A" tag.. any HTML just get's copied as
"shown" HTML tags... but It will accept a Microsoft Document copied
URL from Excel or Word.. My business requirements are to be able to
leverage this type of copy straight from a web page...
I learned a little Rtf language, but need to tell the copy mechanism
this is the type of format I'm using...

If you copy a HTML-encoded or RTF-encoded hyperlink, it is still text.

In IE, it is possible to right-click a link and select the built-in
"Copy hyperlink" menu option. You could then paste the URL anywhere.
Does the Outlook Signature box not accept it? It should. I can't tell
for sure, as I do not have Outlook.

I do know that Outlook uses Word as the web page rendering engine but
something that has been copied to they Clipboard should be available for
paste operations anywhere. Just confirm the above does not work.
 
G

galactic

On Mar 25, 4:07 pm, galactic wrote:

 > I just need to know if you know what format to place
 > instead of "Text"
 >
 >   window.clipboardData.setData("Text", rng.htmlText);
 >
 > I need it to show up in the clipboard as Rich Text only.

Look up clipboardData on msdn. --Antony

Thanks, but I have. It does not give accurate information for
javascript. It will for aspx...

I'm trying to get this done in javascript, and the acceptable datatype
is "Rtf" according to the MSDN website - but this does not work for
me... any ideas?

-galactic
 
A

Antony Scriven

Thanks, but I have. It does not give accurate information
for javascript. It will for aspx...

It's a host object specific to IE.
I'm trying to get this done in javascript, and the
acceptable datatype is "Rtf" according to the MSDN
website - but this does not work for me... any ideas?

I don't know where you got that from. From MSDN:

| Parameters
| sDataFormat Required. A String that specifies the format
| of the data to be transferred, using one of
| the following values.
|
| Text Transfers data formatted as text.
| URL Transfers data formatted as a URL.
 
B

Bwig Zomberi

galactic said:
Thank you BWig,

I just need to know if you know what format to place instead of "Text"

window.clipboardData.setData("Text", rng.htmlText);

I need it to show up in the clipboard as Rich Text only.

Suppose you have a paragraph in a web page (in IE of course) and want
to copy the para with all its formatting as rich text. First, create a
range out of paragraph element with CreateRange. Then use the method
execCommand("Copy") on that range. This will copy the paragraph rich
text to the clipboard.

*You do not have to get your hands dirty with window.clipboardData.*

After you do this, the copied paragraph is available for programs that
can handle rich text in the clipboard. For example, you can open a New
Message window in Outlook or a Word document and do a Paste command.

execCommand will work on a document, range or selection.

BTW, I hope by Rich Text you meant formatted web page content, not
Microsoft Word RTF. MS' RTF is also coded in text and can possibly be
done in JavaScript but your brain will melt.
 
G

galactic

Suppose you have a paragraph in a web page (in IE of course) and want
to copy the para with all its formatting as rich text. First, create a
range out of paragraph element with CreateRange. Then use the method
execCommand("Copy") on that range. This will copy the paragraph rich
text to the clipboard.

*You do not have to get your hands dirty with window.clipboardData.*

After you do this, the copied paragraph is available for programs that
can handle rich text in the clipboard. For example, you can open a New
Message window in Outlook or a Word document and do a Paste command.

execCommand will work on a document, range or selection.

BTW, I hope by Rich Text you meant formatted web page content, not
Microsoft Word RTF. MS' RTF is also coded in text and can possibly be
done in JavaScript but your brain will melt.

Bwig,

Yes I believe the format is the Microsoft RTF - specifically I need to
be able to paste a ready made URL - complete with hidden A tag - into
Outlooks Signature box. The Outlook Signature interface (outlook
version 2003 11.8) will only accept a url as a Microsoft RTF Piece!
(Tools->Options->tabMailFormat->Signiatures.
It will not accept - say an "A" tag.. any HTML just get's copied as
"shown" HTML tags... but It will accept a Microsoft Document copied
URL from Excel or Word.. My business requirements are to be able to
leverage this type of copy straight from a web page...
I learned a little Rtf language, but need to tell the copy mechanism
this is the type of format I'm using...

Thanks for really trying to understand. I appreciate any help you can
suggest more than you know.

-William
 
B

Bwig Zomberi

Bwig said:
If you copy a HTML-encoded or RTF-encoded hyperlink, it is still text.

In IE, it is possible to right-click a link and select the built-in
"Copy hyperlink" menu option. You could then paste the URL anywhere.
Does the Outlook Signature box not accept it? It should. I can't tell
for sure, as I do not have Outlook.

I do know that Outlook uses Word as the web page rendering engine but
something that has been copied to they Clipboard should be available for
paste operations anywhere. Just confirm the above does not work.

I am sorry for the double post. My computer time was a day late and I
did not see my first post.

By "hidden hyperlink", do you mean the URL is different from the innerText?

Then, you need to write an external JS for hyperlinks.

The JS could capture the hyperlink with
external.menuArguments.event.srcElement

You could then create a range and use execCommand, as mentioned earlier,
to copy the hyperlink as is to Clipboard.
 
G

galactic

You could then create a range and use execCommand, as mentioned earlier,
to copy the hyperlink as is to Clipboard.

Bwig,

I believe the only thing that will work for my purposes is the be able
to paste some ready-made Rtf that I create into the clipboard.

My simple question is - how to tell the I.E. clipboard that what is
has is Rtf instead of plain text...

If there is a way it probably lies in

window.clipboard.setData("Text", copied.htmlText);

where text is Rtf.. but it won't recognize that command... maybe it's
something else... I can't seem to find the different options..

-William
 
B

Bwig Zomberi

galactic said:
My simple question is - how to tell the I.E. clipboard that what is
has is Rtf instead of plain text...

If there is a way it probably lies in

window.clipboard.setData("Text", copied.htmlText);

where text is Rtf.. but it won't recognize that command... maybe it's
something else... I can't seem to find the different options..

setData method allows text or URL data. Anything else would be a
violation of the browser security model implemented by IE. In ordinary
desktop application, the same setData method allows data in several
other formats. You can't expect all that to be available in the limited
scope given for VBScript/JScript. To bypass that model, you will need a
signed and user-approved ActiveX.

The best way is, as I mentioned, earlier is to use the functionality
already provided by the browser to copy rich text, not RTF, into
clipboard. And, get clipboard data pasted into Outlook.

If required, you can write a custom Outlook Add-on to process this
clipboard RTF data (in text). Add-On code will not be restricted, unlike
browser security model. I however feel it is totally unnecessary. If you
have dug your heels in RTF, well it is up to you.
 
B

Bwig Zomberi

Bwig said:
The best way is, as I mentioned, earlier is to use the functionality
already provided by the browser to copy rich text, not RTF, into
clipboard. And, get clipboard data pasted into Outlook.

If required, you can write a custom Outlook Add-on to process this
clipboard RTF data (in text). Add-On code will not be restricted, unlike
browser security model.

Correction to 2nd Paragraph: If you want to copy RTF, not rich text,
then you need to write a custom Outlook Add-on to process clipboard text
RTF data. Add-On code will be restricted, unlike browser security model.
 
B

Bwig Zomberi

Bwig said:
Correction to 2nd Paragraph: If you want to copy RTF, not rich text,
then you need to write a custom Outlook Add-on to process clipboard text
RTF data. Add-On code will be restricted, unlike browser security model.


Correction to correction: .... Add-on cod will *not* be restricted,
unlike browser security model.
 
G

galactic

Correction to correction: .... Add-on cod will *not* be restricted,
unlike browser security model.

Bwig,

I can't use any add-on - basically the business requirement was that
someone be able to goto a business page, click and copy a vanity URL
(somedomain.com/fruitflies/) but actually take a tracking variable
with it so we know who actually used it...(somedomain.com/fruitflies/
index.htm?vanity=1)and let them paste that directly into their outlook
signature - which only seems to accept rtf (maybe word version)... I
have seen it done without any add on's at pratyatosa.com/
DiacriticsConverter.htm... This page seems to be able to create rtf
into the clipboard with no add ons...

What I really want to say is Thank you so much no matter what for your
attention to this blog... It is nice to get some reaction...

-Galactic
 
B

Bwig Zomberi

galactic said:
Bwig,

I can't use any add-on - basically the business requirement was that
someone be able to goto a business page, click and copy a vanity URL
(somedomain.com/fruitflies/) but actually take a tracking variable
with it so we know who actually used it...(somedomain.com/fruitflies/
index.htm?vanity=1)and let them paste that directly into their outlook
signature - which only seems to accept rtf (maybe word version)... I
have seen it done without any add on's at pratyatosa.com/
DiacriticsConverter.htm... This page seems to be able to create rtf
into the clipboard with no add ons...

I do not have Outlook 2003. I installed Outlook 2010 Beta. The signature
box in this version accepts any content copied using "Copy" and "Copy
shortcut" menu options of IE.

I went to http://pratyatosa.com/DiacriticsConverter.htm but did not find
the link that copied RTF to clipboard.

I wrote the following web page code to simulate the behavior of your
"somedomain.com/fruitflies/index.htm?vanity=1". That also works with the
signature box.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta name="generator" content="Bluefish 2.0.0" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" >
function changeLink(oLink) {
oLink.outerHTML = "<a href=\"http://www.example.com/index.htm?id=" +
Math.random() + "\">Outlook Link</a>";
}
</script>
</head>
<body>

<a href="http://www.example.com/index.htm"
onmouseover="changeLink(this);">Outlook Link</a>

</body>
</html>

You could replace Math.random with getCookie of a unique tracking cookie
value set by your server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top