How to set the comment size in VBA

ssunchen

New Member
Joined
Apr 19, 2002
Messages
17
Hi,

I used Record Macro to create a comment. The VBA code is as follow:

Range("C1").Select
Range("C1").AddComment
Range("C1").Comment.Visible = False
Range("C1").Comment.text text:="Test: A1 " & Chr(10) & "Result: 56"
Selection.ShapeRange.ScaleWidth 5.87, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 2.26, msoFalse, msoScaleFromTopLeft


Once run Macro, get a error message:"Object doesn't support this property or method" for the statement "Selection.ShapeRange.ScaleWidth 5.87, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 2.26, msoFalse, msoScaleFromTopLeft"


Please help!! Big Thanks!!
ssunchen
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try this one: you are on the right way, i just used related Comment.Shape object to set scaleheight and width.

With Range("C1")
.Select
.AddComment
With .Comment
.Visible = False
.Text Text:="Test: A1 " & Chr(10) & "Result: 56"
.Shape.ScaleHeight 2.26, msoFalse, msoScaleFromTopLeft
.Shape.ScaleWidth 5.87, msoFalse, msoScaleFromTopLeft
End With
End With


Regards
This message was edited by smozgur on 2002-04-20 14:54
This message was edited by smozgur on 2002-04-20 14:54
 
Upvote 0
On 2002-04-20 12:36, ssunchen wrote:
Hi,

I used Record Macro to create a comment. The VBA code is as follow:

Range("C1").Select
Range("C1").AddComment
Range("C1").Comment.Visible = False
Range("C1").Comment.text text:="Test: A1 " & Chr(10) & "Result: 56"
Selection.ShapeRange.ScaleWidth 5.87, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 2.26, msoFalse, msoScaleFromTopLeft


Once run Macro, get a error message:"Object doesn't support this property or method" for the statement "Selection.ShapeRange.ScaleWidth 5.87, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 2.26, msoFalse, msoScaleFromTopLeft"


Please help!! Big Thanks!!
ssunchen

You haven't got the comment selected...but
then there is no need to select an object
in order to change it.

Try:

<pre/>
Range("C1").Select
Range("C1").AddComment
Range("C1").Comment.Visible = False
Range("C1").Comment.Text Text:="Test: A1 " & Chr(10) & "Result: 56"
Range("C1").Comment.Shape.ScaleWidth 5.87, msoFalse, msoScaleFromTopLeft
Range("C1").Comment.Shape.ScaleHeight 2.26, msoFalse, msoScaleFromTopLeft

</pre>

Or tidier;

</pre>
Sub Tidy()
With Range("C1")
.AddComment
.Comment.Text Text:="Test: A1 " & Chr(10) & "Result: 56"
.Comment.Shape.ScaleWidth 5.87, msoFalse, msoScaleFromTopLeft
.Comment.Shape.ScaleHeight 2.26, msoFalse, msoScaleFromTopLeft
End With
End Sub

</pre>
 
Upvote 0
Comments eh! i hated them as BOARING in till Ivan F Moala showed me they ant gotta be i have sweet little blue and white clouds!

What i found was the size was a pain and recorded them if regula size was required and so saved the agro and added the lines of code in, thus me being lazy.

i sent Ivan these as thanks to him for the pointer, sad no excel i have so no code at disposal.. Thus why i rairly post my VBA
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

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