+ Reply to Thread
Results 1 to 8 of 8

Cell Comment Truncating String?

  1. #1
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Cell Comment Truncating String?

    I form a string and put that string into a selected cell as a comment. Mostly it works fine but as the string gets over a certain length (255 characters?), the string gets "truncated" in that only the characters over that length get put into the comment.

    Here's the code that I use:

    Please Login or Register  to view this content.
    The sStr variable is correctly formed (as seen with the msgBox) prior to the time that I try to put it into the comment.

    Any ideas what I'm doing wrong?

    TIA.

    Bob
    Last edited by bstubbs; 06-11-2009 at 02:56 PM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Cell Comment Truncating String?

    You need to break the string up into sections and pass those to the comment using the Characters.Insert method. See this MSKB article for example. (states it's for Excel 97, but it's still not fixed to the best of my knowledge)
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: Cell Comment Truncating String?

    Ok, that makes sense to me. The problem that I next run into, I think, is that, since I'm tied to using cell comment (different than putting the data into the cell with characters.insert routines, right?), I'm limited to comments of less than 255 characters. I can bust the string into manageable subStrings but addComment only works with a blank cell comment as I understand it. Any ideas how I can concatentate the substrings into the comment given the addComment string limitation?

    TIA.

    Bob

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Cell Comment Truncating String?

    Hello Bob,

    I just did some testing and found the maximum character width of a comment is 255 characters. This holds true regardless of the font size. So you would need break the string at multiples of 254 characters and add a vbLf character at the end.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: Cell Comment Truncating String?

    Thanks. What routine did you use to get the less-than-255 strings into the comment field and concantenate them there? Can you provide the proto-typed code?

    Again, thanks for your help.

    Bob

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Cell Comment Truncating String?

    Try this:
    Please Login or Register  to view this content.
    Last edited by shg; 06-11-2009 at 04:14 PM. Reason: Added some stuff
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: Cell Comment Truncating String?

    Thank you.

    I had to take out the "stop" line and add in an autosize statement but it worked like a charm.

    Bob

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Cell Comment Truncating String?

    I had to take out the "stop" line
    Oops. I was watching it fill incrementally.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1