Resize Comment Box

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,644
Office Version
  1. 365
Platform
  1. Windows
Is it possible to resize a comment box that has been added via code?

I recorded the resize and added the code to my routine but it doesn't seem to like it
Code:
                    With Selection.Offset(intCellShadeRow, intCellShadeCol)
                        .Interior.ColorIndex = intCellShade
                        .Font.ColorIndex = intCellShade
                        If strComment = "" Then
                            Else
                            .AddComment.Text strComment
                            .ShapeRange.ScaleHeight 0.2, msoFalse, msoScaleFromTopLeft
                        End If
                    End With
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try something like this:

Code:
Public Sub Test()

Dim oCell As Range
Dim oComment As Comment

Set oCell = Selection

Set oComment = oCell.Cells(1).Comment

If Not oComment Is Nothing Then
    oComment.Shape.Width = oComment.Shape.Width * 2
    oComment.Shape.Height = oComment.Shape.Height * 2
Else
    Set oComment = oCell.Cells(1).AddComment
    With oComment
        .Shape.TextFrame.Characters.Text = "Hello world"
        .Shape.Width = 400
        .Shape.Height = 50
    End With
End If

End Sub

Gary
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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