ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to change comment Box width and high (https://www.excelbanter.com/excel-programming/434133-how-change-comment-box-width-high.html)

moonhk[_2_]

How to change comment Box width and high
 
Hi All

How to change comment Box width and high.

Below is records vba, but Selection.ShapeRange.ScaleWidth have error.
How to change set comment Width ?


Sub Macro1()
'

Range("S19").AddComment
Range("S19").Comment.Visible = true
Range("S19").Comment.Text Text:="e:" & Chr(10) & ""
Selection.ShapeRange.ScaleWidth 5.05, msoFalse,
msoScaleFromBottomRight
Selection.ShapeRange.ScaleWidth 1.24, msoFalse,
msoScaleFromTopLeft
Range("S19").Comment.Shape.Select True
Range("S19").Comment.Text Text:="e:" & Chr(10) & "zxdfdf"
Range("S23").Select
End Sub

Rick Rothstein

How to change comment Box width and high
 
I'm not 100% sure what height and width you ultimately want, but here is
some code for you to look at that adds the comment and sets the text, height
and width for it...

Sub AddComment()
With Range("S19")
On Error Resume Next
.Comment.Delete
On Error GoTo 0
.AddComment
With .Comment
.Visible = True
.Shape.TextFrame.Characters.Text = "Line One" & Chr(10) & "Line Two"
.Shape.Width = 75
.Shape.Height = 100
End With
End With
End Sub

Note: The With/End With blocking cuts down on a whole lot of typing.

--
Rick (MVP - Excel)


"moonhk" wrote in message
...
Hi All

How to change comment Box width and high.

Below is records vba, but Selection.ShapeRange.ScaleWidth have error.
How to change set comment Width ?


Sub Macro1()
'

Range("S19").AddComment
Range("S19").Comment.Visible = true
Range("S19").Comment.Text Text:="e:" & Chr(10) & ""
Selection.ShapeRange.ScaleWidth 5.05, msoFalse,
msoScaleFromBottomRight
Selection.ShapeRange.ScaleWidth 1.24, msoFalse,
msoScaleFromTopLeft
Range("S19").Comment.Shape.Select True
Range("S19").Comment.Text Text:="e:" & Chr(10) & "zxdfdf"
Range("S23").Select
End Sub



moonhkt

How to change comment Box width and high
 
Hi All
Yes. Also how to set font name and font size ?

Sub AddComment()
With Range("A1")
On Error Resume Next
.Comment.Delete
On Error GoTo 0
.AddComment
With .Comment
.Visible = False
.Shape.TextFrame.Characters.Text = "Line One" & Chr(10) & "Line
Two"
.Shape.Width = 500
.Shape.Height = 200

End With
End With
End Sub



On 9月25日, 下午10時43分, "Rick Rothstein"
wrote:
I'm not 100% sure what height and width you ultimately want, but here is
some code for you to look at that adds the comment and sets the text, height
and width for it...

Sub AddComment()
* With Range("S19")
* * On Error Resume Next
* * .Comment.Delete
* * On Error GoTo 0
* * .AddComment
* * With .Comment
* * * .Visible = True
* * * .Shape.TextFrame.Characters.Text = "Line One" & Chr(10) & "Line Two"
* * * .Shape.Width = 75
* * * .Shape.Height = 100
* * End With
* End With
End Sub

Note: The With/End With blocking cuts down on a whole lot of typing.

--
Rick (MVP - Excel)

"moonhk" wrote in message

...

Hi All


How to change comment Box width and high.


Below is records vba, but Selection.ShapeRange.ScaleWidth *have error.
How to change *set comment Width ?


Sub Macro1()
'


* *Range("S19").AddComment
* *Range("S19").Comment.Visible = true
* *Range("S19").Comment.Text Text:="e:" & Chr(10) & ""
* *Selection.ShapeRange.ScaleWidth 5.05, msoFalse,
msoScaleFromBottomRight
* *Selection.ShapeRange.ScaleWidth 1.24, msoFalse,
msoScaleFromTopLeft
* *Range("S19").Comment.Shape.Select True
* *Range("S19").Comment.Text Text:="e:" & Chr(10) & "zxdfdf"
* *Range("S23").Select
End Sub




All times are GMT +1. The time now is 09:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com