VBA for green empty comment

K

Klemen25

Hello all

I formed the following macro to add green empty comment:
But the line ActiveCell.Comment.Shape.Select is not ok and I get
error:
Method "select" of the object "shape" failed.
Any soluions :(
Thank you!



Sub comment2()
Dim cmt As comment
Set cmt = ActiveCell.comment
If cmt Is Nothing Then
ActiveCell.AddComment Text:=""
ActiveCell.Comment.Shape.Select
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 42
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)

End If
SendKeys "%i{DOWN}e~"
End Sub
 
M

michdenis

Sub comment2()
Dim cmt As Comment
Set cmt = ActiveCell.Comment
If cmt Is Nothing Then
Set cmt = ActiveCell.AddComment(Text:="")
With cmt.Shape
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = 42
.Fill.Transparency = 0#
.Line.Weight = 0.75
.Line.DashStyle = msoLineSolid
.Line.Style = msoLineSingle
.Line.Transparency = 0#
.Line.Visible = msoTrue
.Line.ForeColor.RGB = RGB(0, 0, 0)
.Line.BackColor.RGB = RGB(255, 255, 255)
End With
End If
SendKeys "%i{DOWN}e~"
End Sub





"Klemen25" <[email protected]> a écrit dans le message de (e-mail address removed)...
Hello all

I formed the following macro to add green empty comment:
But the line ActiveCell.Comment.Shape.Select is not ok and I get
error:
Method "select" of the object "shape" failed.
Any soluions :(
Thank you!



Sub comment2()
Dim cmt As comment
Set cmt = ActiveCell.comment
If cmt Is Nothing Then
ActiveCell.AddComment Text:=""
ActiveCell.Comment.Shape.Select
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 42
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)

End If
SendKeys "%i{DOWN}e~"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top