Resize of comments box / shape etc

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
Hi,
Please can you advise on my code as i have an issue i am unable to sort.

The shape is to small for the amount of text within it,ive tried to add like .Autoresize = False etc but just got errors.
Shape needs to expand to allow all the text to be read.



Rich (BB code):
 For Each MyComments In ActiveSheet.Comments
            With MyComments
                .Shape.AutoShapeType = msoShapeRoundedRectangle
                .Shape.TextFrame.Characters.Font.Name = "Times Roman" 'FONT STYLE CORRECT
                .Shape.TextFrame.Characters.Font.Size = 20  'TEXT SIZE CORRECT
                .Shape.TextFrame.Characters.Font.ColorIndex = 1 'TEXT COLOR CORRECT
                .Shape.LINE.ForeColor.RGB = RGB(255, 0, 255)
                .Shape.LINE.BackColor.RGB = RGB(255, 255, 255)
                .Shape.Fill.Visible = msoTrue
                .Shape.Fill.ForeColor.RGB = RGB(0, 255, 255) ' FILL COLOR CORRECT
                .Shape.Fill.OneColorGradient msoGradientDiagonalUp, 1, 0.23
           End With
          Next 'comment
 

Attachments

  • 471.jpg
    471.jpg
    37.9 KB · Views: 27

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi,

Put this line inside With - End With

.Shape.TextFrame.AutoSize = True
 
Upvote 0
Hi,
It that codee correct as i see.

.Shape.TextFrame.AutoSize = True
 
Upvote 0
Hmmm
Something odd here see screenshot
 

Attachments

  • 473.jpg
    473.jpg
    87.2 KB · Views: 29
Upvote 0
Now applied but doesnt seem correct.

True would send my text just left to right direction continuosly.
False would keep it within aa shape but in respect of going down direction but the shap stays the same size & some text then hidden.

I thought True would adjust to the amount of text
 
Upvote 0
To enter the text below each other, use the Enter key.
I think the font size is too large. I replaced 20 with 12 and it's OK.

You can also try something like:
Let's say that for 100 characters you need a width of 250, and if it exceeds this number of characters then the width will be multiplied by 1.5 or 2.
You will also proceed with the height of the comment.
 
Last edited:
Upvote 0
This works for me. Thankfully my eyesight isn't bad enough to need a font that large ;)
VBA Code:
Sub Adjust_Comments()
    Dim MyComments As Comment

For Each MyComments In ActiveSheet.Comments
    With MyComments
        .Shape.AutoShapeType = msoShapeRoundedRectangle
        .Shape.TextFrame.Characters.Font.Name = "Times Roman"
        .Shape.TextFrame.Characters.Font.Size = 20
        .Shape.TextFrame.Characters.Font.ColorIndex = 1
        .Shape.Line.ForeColor.RGB = RGB(255, 0, 255)
        .Shape.Line.BackColor.RGB = RGB(255, 255, 255)
        .Shape.Fill.Visible = msoTrue
        .Shape.Fill.ForeColor.RGB = RGB(0, 255, 255)
        .Shape.Fill.OneColorGradient msoGradientDiagonalUp, 1, 0.23
        .Shape.TextFrame.AutoSize = True
    End With
Next    'comment

End Sub
 
Upvote 0
Can’t use enter as the text is being sent to worksheet from userform.
Something isn’t right as with NoSparks still I see it no enlarge.

I write on my userform and command button sends values from text boxes to worksheet.
All are placed. In the correct cells.
The text I write is inserted as a comment fine.
So now when I put the cursor over the comment cell in question I see the text but some is outside of the comments frame.

Text text size 20 was left in by mistake. Actually I’m going to use 12

I was trying to get the code to just apply itself to the comment last sent from userform.
By having it at 22 I was able to see if the code was just beeing applied to one cell or all cells.
 
Upvote 0
How about sharing a sample workbook so we're both dealing with the same thing.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top