# How to fill the clipboard with an html table.. the IE way?



## outmarcus (Aug 27, 2005)

Try to copy and paste this code to Word or Frontpage:


123

[TR]
[TR]

You will see that it will be copied "as is"!

While try to display the table in IE, then copy the table in clipboard and paste it in Word or Frontpage: you will see the designed table, not the code!

Why? is it copied differently to the clipboard? how?


----------



## cwwozniak (Nov 29, 2005)

When you paste your code into a blank page in FrontPage in design view, it assumes that you want to actually display the "less than" and "greater than" symbols and not use them as part of the HTML markup. If you look at the HTML code of the page you will see that each "less than" symbol is converted to *<* and each "greater than" symbol isc onverted to *>* . FrontPage also adds 
markups for new lines.

If you paste your lines of text into the file in code view, you get a display of the table in design view.


----------



## outmarcus (Aug 27, 2005)

The problem is that in the second case (when you copy a designed table from IE) when you paste it into a blank page in FrontPage in design view, it *doesn't *assume that you want to actually display the "less than" and "greater than" symbols. It design the table!
Why? I would like to know what must contain the clipboard to work like in this case.


----------



## cwwozniak (Nov 29, 2005)

I was a bit confused by your, "While try to display the table in IE," comment in the original explanation. The page created in FrontPage does not display as a table when previewed in IE.

Not sure if there is a shortcut way to copy the table in IE or paste the code for the copied table as viewable text in FrontPage. Someone else here may have such a solution.

This might work for you: In IE, Select View -> Source from the menu bar and find the code for the table you wish to copy. Then paste into design view view of FrontPage. The hard part would be finding the right chunk of source code in a complicated page.

To find the source code in a complex page, you could also try first opening the source page in FP, go to split view, select the desired table in design view, the code for the selected sections should also be highlighted in the source code ready for copying.


----------



## Hughv (Jul 22, 2006)

This is not a clipboard problem (Use Clipboard Viewer to see that the contents are exactly as you copied them).
HTML code is a text file.
Open this file with Notepad and you'll see exactly what you copied.
Open it with an HTML viewer like IE, FF or Front Page and it's interpreted as HTML.
To test:
Create a Notepad file with this text and save it as "Test" (Use the quotes so no extension is added).
Open with FF, Word or IE and you'll see the table contents (1 2 3). Use "View Source" to see the HTML).
Open it with Notepad, Wordpad or any HTML editor and you'll see the HTML.


----------



## outmarcus (Aug 27, 2005)

Sure, if you save it and open it as a file it is certainly like you wrote.
But try to use the clipboard, try to copy and paste it to FF, Word and you will see the difference: in one case you will see the table, in the other case you will see the code, and in both case you are pasting it to the same (wysiwyg) window!
How do you explain this?


----------



## Hughv (Jul 22, 2006)

I already explained it:
Any program that interprets HTML, like a web browser, will read the code and render it as a table. Most text editors (HTML Code is just text) will just read the text.
In any case, the clipboard doesn't change anything.
If you really want to see how this works, create the file above and open it in FF or IE.
Then change the file extension to .txt and open it. The exact same file will open two different ways.


----------



## outmarcus (Aug 27, 2005)

It's not like you say.

Try to copy and paste the following code to a notepad window:


123

[TR]
[TR]

Then copy it from the notepad window and paste it to whatever page of Frontpage or Word you want. You will see that it doesn't design the table! they just take it as simple text!


----------



## Hughv (Jul 22, 2006)

I'm afraid you've lost your way .
Create the file as I suggested and you'll see what I mean.
This is a very simple concept:
HTML rendering software, like FF, IE or the Design view of FP will render this as a table. That's what they do for a living. BTW, Open Office writer opens this as a table, and so will Word, if it doesn't have an extension.


A text editor like Notepad, and some versions of Word will open this as a text file, because that's what it is, and they don't have any HTML capability
It's just a matter of what the software is designed to do. There's nothing mysterious here, and I don't know any other way to explain it.


----------



## cwwozniak (Nov 29, 2005)

Found this on the MS web site when searching for the words *HTML* and *clipboard*.

*
HTML Clipboard Format*

My brain started to go numb about a third of the way through, but I believe that it is saying that Windows has different ways of treating snippets of HTML code on the clipboard.

EDIT:


Hughv said:


> HTML rendering software, like FF, IE or the Design view of FP will render this as a table.


Not necessarily. As I mentioned in a previous post, if you copy the seven lines of text as given in outmarcus' post and then paste into the design view of FrontPage 2003, they will show up as seven lines of text including "<"and ">", not rendered as a table. The same thing happens if you copy the seven lines of text from a Notepad file txt file.


----------



## outmarcus (Aug 27, 2005)

let me try to explain in other words...

I perfectly know that HTML rendering software, like FF, IE or the Design view of FP RENDERS the table if you open it from a file or if you paste the code in the code view.

What's mysterious here is that if you paste the code of my example from the clipboard to the design view, in some cases it renders it as a designed table, in other cases it renders it as a text!
There is something in the clipboard that tells it to render it as html or as text.... the question is: what?


----------



## outmarcus (Aug 27, 2005)

Ah, I suspect that cwwozniak unveiled the mystery! I'm reading it


----------



## Hughv (Jul 22, 2006)

"Not necessarily. As I mentioned in a previous post, if you copy the seven lines of text as given in outmarcus' post and then paste into the design view of FrontPage 2003, they will show up as seven lines of text including "<"and ">", not rendered as a table. The same thing happens if you copy the seven lines of text from a Notepad file txt file."

OK, but what do you see when you switch to code view? I suspect you'll see the escape codes you mentioned earlier.
I don't see anything in the article that suggests the Clipboard changes anything at all.


----------



## outmarcus (Aug 27, 2005)

Good, Hughv.
Now try to copy a table from this page http://www.w3schools.com/Html/tryit.asp?filename=tryhtml_tables (those on the right) to the clipboard and paste it to the design view of FrontPage 2003 or in Word, and you will understand what I'm trying to explain to you. You will be surprised!


----------



## Hughv (Jul 22, 2006)

That's not a surprise The clipboard copied the text that it saw. It's not a table, just text that's arranged like a table.
The clipboard doesn't change anything. If it did, it would be worthless.
What does the source code show after you paste it?


----------



## cwwozniak (Nov 29, 2005)

Hughv said:


> The clipboard copied the text that it saw. It's not a table, just text that's arranged like a table.


The attached ZIP file is an MS-Word 2003 file. Using Internet Explorer 6, I copied the entire contents of the right hand column of *outmarcus' *last link. I then pasted into a new blank Word document. The borders around the numbers strongly suggest that the text is in a real table and not just arranged like a table.



Hughv said:


> What does the source code show after you paste it?


Pasted the same web page content into the design view of new blank MS-FrontPage 2003 page.The result pretty much looked exactly the same as the MS-Word file. The complete source code view is:


```
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>

<p>Each table starts with a table tag. Each table row starts with a tr tag. Each 
table data starts with a td tag. </p>
<h4>One column:</h4>
<table border="1" id="table1">
	<tr>
		<td>100</td>
	</tr>
</table>
<h4>One row and three columns:</h4>
<table border="1" id="table2">
	<tr>
		<td>100</td>
		<td>200</td>
		<td>300</td>
	</tr>
</table>
<h4>Two rows and three columns:</h4>
<table border="1" id="table3">
	<tr>
		<td>100</td>
		<td>200</td>
		<td>300</td>
	</tr>
	<tr>
		<td>400</td>
		<td>500</td>
		<td>600</td>
	</tr>
</table>

</body>

</html>
```
Sure looks like all of the HTML markup got put on the clipboard along with the visible text.


----------



## Hughv (Jul 22, 2006)

That's interesting, and I think you're right about it being a table.
Still, the contents of the Clipboard are this: (Copied from the clipboard viewer)

"One column:
100
One row and three columns:
100 200 300
Two rows and three columns:
100 200 300
400 500 600"

It has to be Word/Front Page that are adding the HTML.
Interestingly, my HTML Editor, nor FF/IE will accept this as a paste operation in the web view.


----------



## cwwozniak (Nov 29, 2005)

Hughv said:


> It has to be Word/Front Page that are adding the HTML.


How in the world would Word or FrontPage know to add borders and have them at the same thickness as in the original source web page if the information wasn't on the clipboard????

You may just have to accept the fact that clipboard viewer is not really showing you everything when the clipboard is used to copy HTML formatted content.


----------



## Hughv (Jul 22, 2006)

What's the chance that it's the Office clipboard that's doing this? That would be a whole different kettle of fish.I just did a quick test with Word (I don't have Front Page), and if you select from the Office Clipboard "text only" vs. "Keep source formatting". you get what I expected (No HTML) so I think the mystery is solved.


----------



## outmarcus (Aug 27, 2005)

The demonstration is fast: try to copy and paste the little tables at the bottom of this page in the design view of Frontpage, then look at the source code.
How does it know things like "

" and "<a href="http://forums.techguy.org/members/208663-outmarcus.html">", that doesn't show up when you paste it in notepad?


----------



## cwwozniak (Nov 29, 2005)

Am I safe to assume that Firefox would not be using the Office clipboard?

With a slightly older version of the page we are now viewing open in Firefox, I clicked on Edit -> Select all, followed by, Edit -> Copy.

I then launched MS-Word with a new blank document. I clicked in the document and selected Edit -> Paste. It took a few seconds but I ended up with 9 pages of pasted content. I then looked through the content to see if there was any private information to be removed. The results are attached. The MS-Word version of the page does not come close to matching the appearance of web version but it sure has more than just the visible text showing. Looks like some of the graphics, scripts and drop down menus got transferred. There are also some font changes.


----------



## outmarcus (Aug 27, 2005)

I found what I would call the final truth:
use this little clipboard viewer called CLCL to see it! http://www.nonags.com/software.asp?id=241

Copy something in clipboard, then click on its tray bar icon to open this clipboard viewer


----------



## outmarcus (Aug 27, 2005)

So... the evidency shown by CLCL is that IE and Firefox copy to the clipboard multiple versions of the selected text channelled in multiple clipboard formats(?).
The format "TEXT" is filled with the visible text.
The format "HTML Format" is filled with the html source.

Therefore I presume that when you paste it:
- Notepad reads the "TEXT" format of the clipboard
- the code view of Frontpage reads the "TEXT" format of the clipboard
- the design view of Frontpage reads the "HTML Format" format of the clipboard
- Word reads the "HTML Format" format of the clipboard

Do you agree?


----------



## Hughv (Jul 22, 2006)

No.
There are no "versions" of the Windows clipboard.
The Offiice Clipboard is solely responsible for this, IMHO.
cwwozniak's test doesn't help because he used the office clipboard. Try doing it with "Source formatting" turned off and you'll see what I mean.
Disable the clipboard, then try it:
http://support.microsoft.com/kb/207438
This has actually been very educational for me, as I seldom use MS Office and never use Front Page. I don't have anything against the Office Clipboard, but a lot of people do, and I can see why.


----------



## cwwozniak (Nov 29, 2005)

There may be only one application called Windows Clipboard, but it can definitely store multiple versions of the same information in different formats. You can take that up with Microsoft if you disagree.

From http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx :


> *Clipboard Formats*
> 
> A window can place more than one object on the clipboard, each representing the same information in a different clipboard format. Users need not be aware of the clipboard formats used for an object on the clipboard.





Hughv said:


> cwwozniak's test doesn't help because he used the office clipboard. Try doing it with "Source formatting" turned off and you'll see what I mean.
> Disable the clipboard, then try it:
> http://support.microsoft.com/kb/207438


How in the name of the Wide Wide World of Sports can you say I used the "Office Clipboard" in my test?

Here is some information from the page in your link:



> *About the Office Clipboard*
> 
> When you copy multiple items in any of the Microsoft Office programs, the Office Clipboard appears, allowing you to collect and paste multiple items stored in the toolbar. For example, you can copy a chart in Microsoft Excel, switch to Microsoft Word, copy text, and then switch to Microsoft PowerPoint and paste all of the collected (cut or copied) items from the Office Clipboard.


I said that I copied the contents of a page being displayed in the Firefox browser. I am fairly sure that the Firefox browser is NOT a Microsoft product, let alone a part of MS-Office.


----------



## Hughv (Jul 22, 2006)

I'm not looking for a pissing contest here, just an explanation of this bizarre behavior.
From MS:http://support.microsoft.com/kb/221190/EN-US/

"Office 2000 includes a new clipboard called the Office Clipboard. You can use this clipboard to collect and paste multiple items. For example, you can copy a drawing object in Microsoft Excel, switch to Microsoft PowerPoint and copy a bulleted list, switch to Microsoft Internet Explorer and copy a page of text, and then switch to Microsoft Word and paste the collection of copied items.

NOTE: You can copy items while using any program that provides copy and cut functionality, but you can only paste items into Word, Excel, PowerPoint, Microsoft Access, or Microsoft Outlook."

You used the office clipboard, if I understand this right.


----------



## cwwozniak (Nov 29, 2005)

I am fairly sure I was using the plain old Windows clipboard for the test. I'll repeat the test tomorrow and double check.


----------



## Hughv (Jul 22, 2006)

I just checked this with FF, and the paste operation definitely uses the Office Clipboard.
I have another machine without Office, and I'm trying to think of a test that would clarify this. If you have any ideas, let me know.


----------



## outmarcus (Aug 27, 2005)

I made additional research and found that the "HTML Format" clipboard format is technically called "CL_HTML" clipboard format.

This is an MS documents that explains a command for reading the "fragment portion of the CF_HTML clipboard format".
It adds: "This feature might not be available on platforms other than Microsoft Win32 platforms"

So.. my updated opinion is that there are multiple versions (rectius: formats) of the clipboard in "Microsoft Win32 platforms" and that I'm interested to is called "CL_HTML". And that the Office clipboard is another thing.

Feel free to confute this or add more details


----------



## outmarcus (Aug 27, 2005)

From http://msdn.microsoft.com/en-us/library/aa226930(VS.60).aspx :

"Cut and Paste in Design View

When you cut or copy text to the Windows® Clipboard from an HTML source  such as Internet Explorer, Design view of the Visual InterDev editor, or the Visual InterDev Help system or sample applications  two versions of the text become available: an HTML version and a text version."


----------



## Hughv (Jul 22, 2006)

outmarcus said:


> From http://msdn.microsoft.com/en-us/library/aa226930(VS.60).aspx :
> 
> "Cut and Paste in Design View
> 
> When you cut or copy text to the Windows® Clipboard from an HTML source  such as Internet Explorer, Design view of the Visual InterDev editor, or the Visual InterDev Help system or sample applications  two versions of the text become available: an HTML version and a text version."


This seems to only apply to Visual Studio 6.
Answer me this:
On a computer without Office or Visual Studio, what's available on the clipboard?


----------



## outmarcus (Aug 27, 2005)

I tried the CLCL clipboard viewer in a MicroXP virtual machine within VMWare, without anything else installed, and I confirm that about 10 different formats of the clipboard are filled when I copy a piece of a webpage from IE to the clipboard, including the HTML format.

MicroXP is an extremely stripped down version of Windows, in other words it is less than Windows


----------



## cwwozniak (Nov 29, 2005)

outmarcus said:


> ... I confirm that about 10 different formats of the clipboard are filled when I copy a piece of a webpage from IE to the clipboard, including the HTML format.


It appears that I got the same kind of results using a different methodology.

Running on Windows XP Home, I copied a chunk of a web page in Firefox. I then launched Microsoft ClipBook Viewer Version 5.1 located at C:\WINDOWS\system32\clipbrd.exe on my hard drive. The Text, Unicode Text, and OEM Text views showed only the visible text that was copied and did not match the fonts and layout in the original. The HTML View option was grayed out.

I then did a "Save as" NT Clipboard File (*.CLP) to the desktop. I noted that there was no option to save as any kind of "Office Clipboard" file. I changed the extension of the saved file from .CLP to .TXT and opened the file in Notepad. The contents definitely showed a lot more than just the few lines of visible text that were copied and shown in the clipboard viewer. I did not do a line by line check but the content did seem to match what was described in my earlier link on the MS web site. AS FAR AS I WAS CONCERNED, NOTEPAD WAS SHOWING THE CONTENT OF WHAT WAS COPIED TO THE *WINDOWS CLIPBOARD*, NOT ANY KIND OF "OFFICE CLIPBOARD".


----------



## Hughv (Jul 22, 2006)

It looks like you guys are right.
The clp fie isn't just a plain text file anymore, it's in binary form.
This has been very informative.

From Wikipedia:
Data formats
*
Early implementations of the clipboard stored data as plain text without meta-information such as typeface, type style or color*. More recent implementations support the multiple types of data, allowing complex data structures to be stored. These range from styled text formats such as RTF or HTML, through a variety of bitmap and vector image formats to complex data types like spreadsheets and database entries.

For example cutting a range of cells in a spreadsheet and then pasting them into another sheet may preserve the underlying formulae and data, and may even translate intra-cell references, so that a "SUM(...)" calculation on a sub-range of the cells is converted to refer to the newly pasted copies of those cells.

*When data is added to the clipboard by an application, it typically makes it available in as many different data formats as it can.* This includes both native and simpler (or more common) formats that would have a higher chance of being recognized by a wide variety of applications. Thus, when data is pasted into another application, the format that is closest to that application's native format can be used, preserving as much of the original data as possible. In Windows in particular, the internal clipboard functionality of the operating system will automatically translate data from known advanced formats to simpler formats automatically (such as RTF to plain text, or Unicode to ANSI Text), increasing the likelihood that any given application can interpret some form of the original data.


----------



## cwwozniak (Nov 29, 2005)

Hughv said:


> The clp fie isn't just a plain text file anymore, it's in binary form.


Hallelujah!!! You have seen the true light


----------



## outmarcus (Aug 27, 2005)

Thanks Hughv for the additional research.

The link provided by cwwozniak, that is http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx, near to the end of the page shows a table with a compatibility chart that indicates that many of the basic formats, including the CF_BITMAP, are as old as Windows NT.
However I still don't understand why this page doesn't list the CF_HTML format while on the left they put a link "HTML Clipboard Format" that explains it.

Anyway, now my next question is: how can I write a given html code to clipboard in CF_HTML format using Javascript or another FF/IE compatible language (so that I can paste it directly in the wysiwyg view of my favourite editor)?
I posted this new question as a new topic here: http://forums.techguy.org/web-design-development/778202-how-write-clipboard-cf_html.html


----------



## cwwozniak (Nov 29, 2005)

I am getting a bit confused trying to figure out your final goal but let me make a guess ...

You first want copy some HTML formatted web page content from a page displayed in either Firefox or IE. You then wish to paste that content into a WYSIWYG page editor. However, the editor's WYSIWYG view should actually display all of the raw HTML markup tags instead of hiding the tags and using them to format the visible text. The editor would then generate all of the new HTML markup code needed to display the original HTML markup tags as visible text in a browser.

Just let me know if I am right or wrong. If I am wrong, I don't think I could wrap my brain around any correct explanation of what you actually want to do.


----------



## outmarcus (Aug 27, 2005)

No, my final goal is different:
I have a web application that asks for some data then generates some custom html code on-the-fly via Javascript when a button is pressed.
I want to use that code in Frontpage while working in the design view.

The typical method of writing to the clipboard in Javascript only fills the TEXT format of the clipboard with the given html code. This is not good because with it when I paste to the design view of Frontpage I see the html code, while the source view shows modified html code.
The solution is to fill the CF_HTML format of the clipboard with the same html code, so that in the Design view of Frontpage I can paste from the CF_HTML format, obtaining the wanted result.


----------

