Excel macro to modify table comments

From 清冽之泉
Jump to navigation Jump to search

同事用 WPS 做的表格批注,用 MS Office Excel 打开,批注框糊成一小块,看不全,用以下宏可解决。

Sub ResizeAllComments()
    Dim ws As Worksheet
    Dim cmt As Comment
    
    For Each ws In ThisWorkbook.Worksheets
        For Each cmt In ws.Comments
            With cmt.Shape
                .Width = 200 ' 设置批注框宽度,可根据需要调整
                .Height = 50 ' 设置批注框高度,可根据需要调整
            End With
        Next cmt
    Next ws
End Sub

代码来自通义千问,prompt:

用宏批量调整批注框的大小