+ Reply to Thread
Results 1 to 2 of 2

Autosizing comments

  1. #1
    Registered User
    Join Date
    08-29-2006
    Posts
    30

    Autosizing comments

    Ok, I've read over some old topics on this but they aren't really helping. Basically I've come to the conclusion that excel's autosizing of comments just sucks, but maybe there is something else I can do.

    I have a bunch of comments of the form:

    Authors: Johnson, A., May, B., Shaffer, F., Morrison, A., Williams, H.
    Title: A random title that can be short but is usually quite long, such as this one
    Journal: A journal that is also usually quite long, as it includes page numbers, issue date, and so forth
    PUBREF: 1232345

    Now, each of Author, Title, Journal, and PUBREF are separated by linefeeds (Chr(10)) but nothing else, so when I call the autosize command, it makes the width of the comment box way too long.

    I use the following code to account for this:

    If .Comment.Shape.Width > 150 Then
    boxArea = .Comment.Shape.Width * .Comment.Shape.Height
    .Comment.Shape.Width = 150
    .Comment.Shape.Height = (lArea / 150) * 1.1
    End If

    The problem is, this often results in comment boxes that are way too tall. I guess the reason would be that boxArea calculates the area of the comment box even though the entire area isn't used, such as on the PUBREF line which is much shorter than the actual width of the box. Any one got any ideas on a different way to autosize? Maybe I could count characters in my comment box or something...

    Thanks

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524
    Sub FitComments()
    Dim c As Comment
    For Each c In ActiveSheet.Comments
    c.Shape.TextFrame.AutoSize = True
    Next c
    End Sub


    to see the site where this code is, go here
    http://www.mvps.org/dmcritchie/excel/ccomment.htm

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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