Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comment box resizing

Status
Not open for further replies.

Queryman

Programmer
Joined
Nov 4, 2002
Messages
243
Location
US
I have this code that I used to widen the width of comment boxes that appear as po-ups when the mouse is on them, but I get an error when I run the macro in excel 2002. It says the object does not support this property or function.



Sub COMMENT_TEST()
Range("B4").Comment.Text Text:="Michael D:" & Chr(10) & "THIS IS THE TEST COMMENT" & Chr(10) & ""
Selection.ShapeRange.ScaleWidth 1.38, msoFalse, msoScaleFromTopLeft
Range("B4").Select
End Sub



The "Selection" line is where I get the error.

Michael

 
Here is some code that works. There may be an easier way, but I wasn't able to find one.
Code:
Option Explicit
Sub Test()
Const WORK_CELL = "B4"
Dim r As Range
Dim i As Integer
  With ActiveSheet
    Set r = Range(WORK_CELL)
Code:
    ' Set/reset a comment for the cell...
Code:
    On Error Resume Next
Code:
 ' In case cell already has comment
Code:
    r.AddComment Text:="x"
    r.Comment.Text Text:="Michael D:" & Chr(10) & "THIS IS THE TEST COMMENT" & Chr(10) & ""
Code:
    ' Find the comment in the shape in collection and apply a ScaleWidth...
Code:
    For i = 1 To .Shapes.Count
      If .Shapes(i).Name = r.Comment.Shape.Name Then
        .Shapes(i).ScaleWidth 1.38, msoFalse, msoScaleFromTopLeft
      End If
    Next i
    Set r = Nothing
  End With
End Sub
Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top