Resize & Reposition Comments

collectorskingdom

New Member
Joined
Feb 10, 2018
Messages
3
Hello. I'm new to the forum and I am not well versed in VBA. As you are aware, comments
frequently get moved and resized.
With the help of a friend, I was able to get the following macro to
properly resize and reposition all comments in each worksheet within my workbook. I
t worked great for about 6 months, but now it does not work any more.
When I "comment out" the "On Error Resume Next,"
I receive a "Run-time error '1004': Application-defined or object-defined error."
The macro errors at "
cmt.Shape.TextFrame.AutoSize = True."

I tried some of the solutions I saw in earlier threads that appeared to serve the same purpose, but I could not get them to work properly.

Here's what used to work for me:
Public AppWB As Workbook
Sub Auto_Open()
AppWBName = ThisWorkbook.Name
Set AppWB = Workbooks(AppWBName)
Dim ws As Worksheet
On Error Resume Next
For Each ws In AppWB.Worksheets
For Each cmt In ws.Comments
'Modify your comment code
cmt.Shape.TextFrame.AutoSize = True
cmt.Visible = False
cmt.Shape.Top = cmt.Parent.Top - 10
cmt.Shape.Left = cmt.Parent.Offset(,1).Left + 10
Next
Next ws
End Sub

Thank you in advance.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
It might be looking for a Dim statement
Code:
Dim cmt As Object

I don't see a problem with the syntax if you are using a PC. Don't know about MAC. Also, make sure you have at least one comment.
 
Last edited:
Upvote 0
JLGWhiz, thank you for responding. I am using a Windows 10. I tried using "Dim cmt As Object" and ensuring there is a comment on every worksheet, but it did not solve the problem. I pasted my original code in a new workbook with a simple comment and it worked just fine.
 
Upvote 0
JLGWhiz, thank you for responding. I am using a Windows 10. I tried using "Dim cmt As Object" and ensuring there is a comment on every worksheet, but it did not solve the problem. I pasted my original code in a new workbook with a simple comment and it worked just fine.

That seems to eliminate the basic code as the problem. Now, the trick is to find out what in the previous file prevented the code from producing the desired results. Kind of hard to troubleshoot that one from afar.
regards, JLG
 
Upvote 0
That seems to eliminate the basic code as the problem. Now, the trick is to find out what in the previous file prevented the code from producing the desired results. Kind of hard to troubleshoot that one from afar.
regards, JLG

Thanks, JLG. I was afraid you'd say that. :) I guess it's back to the drawing board. Thanks for your help. Best wishes!
 
Upvote 0

Forum statistics

Threads
1,215,759
Messages
6,126,728
Members
449,332
Latest member
nokoloina

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