Ironman
Well-known Member
- Joined
- Jan 31, 2004
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
Hi
I have a number of notes (Microsoft 365 term for Comments) that contain different font sizes.
Is it possible to change all of these to font size 7 using VBA?
I have tried inserting
in some existing code as below, that resizes and relocates notes boxes and it errored 438 "Object doesn't support this property or method".
Thanks!
I have a number of notes (Microsoft 365 term for Comments) that contain different font sizes.
Is it possible to change all of these to font size 7 using VBA?
I have tried inserting
VBA Code:
.Font.Size = 7
VBA Code:
Sub AutosizeAndRelocateComments()
Application.ScreenUpdating = False
Dim x As Range, y As Long
For Each x In Cells.SpecialCells(1)
Select Case True
Case Len(x.NoteText) <> 0
With x.Comment
.Font.Size = 7
.Shape.TextFrame.AutoSize = True
If .Shape.Width > 250 Then
y = .Shape.Width * .Shape.Height
.Shape.ScaleHeight 0.75, msoFalse, msoScaleFromTopLeft
.Shape.ScaleWidth 1#, msoFalse, msoScaleFromTopLeft
End If
End With
End Select
Next x
Dim cmt As Comment
For Each cmt In ActiveSheet.Comments
cmt.Shape.Top = cmt.Parent.Top + 5
cmt.Shape.Left = _
cmt.Parent.Offset(0, 1).Left + 5
Next
Application.ScreenUpdating = True
End Sub
Thanks!