Example - PasteFromWord


The example code below gets HTML data from the clipboard (if any exists) and converts it to standard HTML (if it needs to be converted). Thereafter it copies the updated HTML back to the clipboard.
 
private void PasteFromWord()
{
   // Get HTML data from the clipboard
   string sHtml = CHtmlClipboard.CopyFromClipboard();

   // Check that string is not empty
  
if (sHtml.Length > 0)
   {
      // Check if string contains Word tags (which is the case if the source is Word)
      if (CWordHtmlConverter.ContainsWordTags(sHtml))
      {
         // Convert Word tags to standard HTML tags (clean the HTML)
         sHtml = CWordHtmlConverter.ConvertWordToCleanHtml(sHtml);

         // Copy the converted & cleaned HTML back to clipboard
         CHtmlClipboard.CopyToClipboard(sHtml);

         // Below you can insert code that pastes the contents of the clipboard
         // to, for example, a HTML editor

         ...
      }
   }
}


< Go Back
 

 
 
SamLogic