Format Comment using VBA

Eric Strobel

New Member
Joined
Oct 4, 2018
Messages
4
I currently am able to use vba to comment a picture I have rooted in a specific cell, but am having trouble sizing it properly. My current code is below:

Sub Comment()

Set rng = ActiveSheet.Cells(9, 1)
rng.AddComment
rng.Comment.Text Text:=""
rng.Comment.Shape.Fill.UserPicture (Sheets("Metrics").Range("B31"))
rng.Comment.ShapeRange.ScaleWidth = Sheets("Metrics").Range("I44")
rng.Comment.ShapeRange.ScaleHeight = Sheets("Metrics").Range("K44")


End Sub

As stated prior, the image with root in B31 is inserted without any issues, but I can't get the comment to scale by the values in cells I44 and K44.
Any help would be appreciated, as I am not really sure what I am doing wrong. Thanks in advance,

Eric
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try...

Code:
Rng.Comment.Shape.ScaleWidth Factor:=Sheets("Metrics").Range("I44"), RelativeToOriginalSize:=msoFalse, Scale:=msoScaleFromTopLeft
Rng.Comment.Shape.ScaleHeight Factor:=Sheets("Metrics").Range("K44"), RelativeToOriginalSize:=msoFalse, Scale:=msoScaleFromTopLeft

Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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