none
need comment to be formatted thru html RRS feed

  • Question

  • I am trying to populate comments in a worksheet through VSTO that have html tags in the text.  I want the comment formatted based on the html.  I have the html stored in array for all columns on worksheet based on code below but I need to format somehow like pastespecial with unicode text.  I don't know how to do that with VSTO.  Any help would be greatly appreciated.

     

    Dim comt As Excel.Comment = ws.Range("A4").AddComment

    comt.Text(comments(2))

    Tuesday, April 5, 2011 5:49 PM

Answers

All replies

  • Hi ard247

    Neither Excel nor Word has a facility for "converting" HTML to formatted text. The only time that's available is when pasting HTML from the Clipboard (Paste method of the object model).

    If you don't want to do that, then your code needs to analyze the HTML and apply the appropriate formatting explicitly.


    Cindy Meister, VSTO/Word MVP
    Wednesday, April 6, 2011 2:03 PM
    Moderator
  • i am doing the formatting thru my code but cannot figure out how to replace the tags with ""... as is shown below with part of my code.  am trying to use the replace function on cmnt after all the formatting is done but cannot get the syntax right?????

     

    Dim cmnt As

    Excel.Comment

    cmnt = rng.AddComment(iComment.ToString)

     

    'find the underlined text which is delimitered by <u></u>

    iBreakBeg2 = InStr(iStart2, cmnt.Text,

    "<u>")

     

    If iBreakBeg2 <> 0 Then

    iBreakEnd2 = InStr(iBreakBeg2, cmnt.Text,

    "</u>")

     

    With cmnt.Shape.TextFrame

    .Characters(iBreakBeg2 + 3, iBreakEnd2 - (iBreakBeg2 + 3)).Font.Underline =

    True

     

    End With

     

    End If
    Thursday, April 7, 2011 5:16 PM
  • Hi Ard

    I think what you need is the .Characters(start, length).Delete() method?


    Cindy Meister, VSTO/Word MVP
    Friday, April 8, 2011 9:48 AM
    Moderator
  • yes! that will do it, thanks so much!!!
    Friday, April 8, 2011 10:34 AM