Consulting

Results 1 to 4 of 4

Thread: Rich Text

  1. #1

    Rich Text

    Is it possible to read and write Rich Text to a cell? By setting the cells value property, copy/pasting the cell or any other method. I don't need to use any complicated Rich Text, just the basic bold, italic, underline tags.

    e.g.

    This is {\i italic and {\b BOLD}} text.

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Have you looked at the .Characters propety of a range?
    (The two arguments of .Characters property are similar to the last two arguments of the Mid function.)
    Record a macro of you setting the middle characters of a cell to red, and that will give you a starting point for those possibilities.

    Setting the .Value property of a cell removes all its rich text formatting.

  3. #3
    VBAX Mentor tpoynton's Avatar
    Joined
    Feb 2005
    Location
    Clinton, MA
    Posts
    399
    Location
    this carbon copies A1 into B1

    [vba]Sub copycell()
    Cells(1, 1).Copy
    Cells(1, 2).PasteSpecial xlPasteAll
    End Sub[/vba]

    EDIT - perhaps I dont get the question, as I read it totally different than Mikerickson

  4. #4
    The Rich Text is coming from anoter source external to excel. Specifically, I am reading the text from a DOORS database, but essentially I end up with the text in a string variable.

    Now, how do I set the text and formatting of a cell with the string?
    I can parse the string myself and read the tags, setting each characters formatting as necessary, but I thaught there would be a easier, automatic way. It is slow to parse each string and format the characters. Using the clipboard seemed like a plan and then PasteSpecial but I can't get it working. Ideally I want to read a cell back as Rich Text too so I can write a string to the database, but that is not as important.

    The text may need to be surrounded by the \rtf1 tag I guess, but that is not problem:

    {\rtf1 This is {\i italic and {\b BOLD}} text.}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •