excel - Excel 2016 for Mac 中的自动调整注释框大小

标签 excel vba macos excel-2016

我已更新到 Excel 2016,以下在 Excel 2011 中运行的代码会生成此错误。
Run-time error '1004' Method 'TextFrame' of object 'Shape' failed

Dim Commnt As Comment
    
For Each Commnt In Application.ActiveSheet.Comments ' Autosize all comment boxes on the sheet
    Commnt.Shape.TextFrame.AutoSize = True
Next
在 Excel 2016 中自动调整所有工作表注释的任务是如何完成的?
经过进一步研究,我尝试了以下但没有成功。
Dim Shp As Shape
For Each Shp In wks1.Shapes
    With Shp.TextFrame2
        .AutoSize = msoAutoSizeShapeToFitText
        .WordWrap = msoTrue
    End With
Next Shp

最佳答案

如 MSDN 中所述,Comment 的 TextFrame(和 TextFrame2)属性在 Excel 2016 中是只读的。

https://msdn.microsoft.com/en-us/vba/excel-vba/articles/shape-textframe-property-excel
https://msdn.microsoft.com/en-us/vba/excel-vba/articles/shape-textframe2-property-excel

使用 Excel 365 进行的快速测试表明,可以使用 Shape 对象本身的 Autosize 属性来自动调整注释大小。

Dim Commnt As Comment

For Each Commnt In Application.ActiveSheet.Comments ' Autosize all comment boxes on the sheet
    Commnt.Shape.AutoSize = True
Next

但是,这似乎不适用于 Excel 2016。

关于excel - Excel 2016 for Mac 中的自动调整注释框大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51448123/

相关文章:

angular - 使用 Visual Studio 在 Mac 上创建一个新的 Angular 项目

excel - 具有多个范围和多个条件的 CountIFS

excel - 在不使用 Excel 的情况下检查 Excel 文件是否以兼容模式保存

excel - 将一维数组(变体类型)转换为一维数组(字节类型)

excel - 在 VBA 中将 Excel 中的文本转换为数字

excel - 范围和变量范围之间的差异

ios - 当我打开 .swift/.xib 文件时 XCode 8.1 崩溃

c++ - Mac OSX libc++ 缺少 std::uncaught_exceptions 符号

excel - 获取最近截止日期的相应值

excel - 导入兼容模式工作簿时遇到问题