VBA and Excel 2019 Comments

JamesPW

Board Regular
Joined
Nov 4, 2005
Messages
51
Office Version
  1. 2019
Platform
  1. MacOS
I just up?graded to MS Office for Mac and Excel 2019 for Mac. I'm trying to duplicate macros I had in Excel 2011 in Excel 2019.
I'm finding there are many changes to VBA between 2011 and 2019..

My problem is with comments. I'm trying to set the text in the comment attached to the current cell to size 12, font bold to false, size to 200x75.
This is only for the currently selected cell, not across the whole spreadsheet.
Here's the code from Excel 2011,

Option explicit
Sub FormatComment()
'Format text
With Selection.Comment.Shape.TextFrame
.Characters.Font.Size = 12
.Characters.Font.Bold = False
End With
'Set size
With Selection.Comment
.Shape.Width = 200
.Shape.Height = 75
End With
Selection.Comment.Visible = True
End Sub

This runs fine in VBA 2011, in VBA 2019 it chokes on "With Selection.Comment.Shape.TextFrame"
Run-Time Error '1004':
Application-Defined or Object-Defined Error

I've googled the dickens out of this and have not found a solution.
So- how do you format a comment in VBA 2019
 
I just up?graded to MS Office for Mac and Excel 2019 for Mac. I'm trying to duplicate macros I had in Excel 2011 in Excel 2019.
I'm finding there are many changes to VBA between 2011 and 2019..

My problem is with comments. I'm trying to set the text in the comment attached to the current cell to size 12, font bold to false, size to 200x75.
This is only for the currently selected cell, not across the whole spreadsheet.
Here's the code from Excel 2011,

Option explicit
Sub FormatComment()
'Format text
With Selection.Comment.Shape.TextFrame
.Characters.Font.Size = 12
.Characters.Font.Bold = False
End With
'Set size
With Selection.Comment
.Shape.Width = 200
.Shape.Height = 75
End With
Selection.Comment.Visible = True
End Sub

This runs fine in VBA 2011, in VBA 2019 it chokes on "With Selection.Comment.Shape.TextFrame"
Run-Time Error '1004':
Application-Defined or Object-Defined Error

I've googled the dickens out of this and have not found a solution.
So- how do you format a comment in VBA 2019
Just got it working on a mac. If anyone still interested
With Selection.Comment.Shape
.ScaleWidth 1.7115384615, msoFalse, msoScaleFromTopLeft
.ScaleHeight 1.231884058, msoFalse, msoScaleFromTopLeft
End With
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,215,339
Messages
6,124,381
Members
449,155
Latest member
ravioli44

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