views:

22

answers:

1

Hi, I'm working on a project where I have created Office Addin's for Excel, Word, Powerpoint and Outlook. I have a button that is supposed to get the get the whatever the user has selected and import it into a WYSIWYG editor. For now this is how I get the selection and extract html.

Excel.Worksheet sheet = excelApp.ActiveSheet;
excelApp.ActiveWindow.RangeSelection.Copy();
if (Clipboard.ContainsText(TextDataFormat.Html))
   html = (Clipboard.GetData(DataFormats.Html).ToString());

Then I modify the html a bit to get rid of all the extra garbage it gives me. The issue is that if non-ASCII symbols are highlighted, for example こんにちは, then the returned html contains incorrect data in it's place. Any idea's would be greatly appreciated. (I have similar issues with Word so let me know of any ideas for that!) Thanks, Phil

A: 

You need to change to DataFormats.UnicodeText. Those are multi-byte characters.

Pweebt
I think the actual issue is that there is an error when reading from the Clipboard. I needed the HTML so UnicodeText wouldn't be enough. For anyone who experiences this problem in the future, I was able to solve it using these two links.http://www.devnewsgroups.net/windowsforms/t25839-character-encoding-problems-reading-html-clipboard.aspxhttp://thinkers-soapbox.spaces.live.com/blog/cns!F58CA5D61B13C153!186.entry
Phil