Excel 使用Shape.Fill.UserPicture()的MacOS上出现错误445

Excel 使用Shape.Fill.UserPicture()的MacOS上出现错误445,excel,vba,macos,Excel,Vba,Macos,我试图在MacOS Excel中使用一些在Windows中运行良好的代码。由于Excel 365 for MacOS中缺少该前端功能,因此该代码会将图像添加到注释中 步骤: 我使用GetOpenFilename()并浏览有效文件 我使用LoadPicture()成功地将图像文件作为对象获取,因此我知道文件和路径都很好 当我尝试使用Fill.UserPicture()时,出现了错误445。我还尝试将Obj直接馈送到UserPicture(),但得到了相同的结果 这是否告诉我后端功能也缺失了 我

我试图在MacOS Excel中使用一些在Windows中运行良好的代码。由于Excel 365 for MacOS中缺少该前端功能,因此该代码会将图像添加到注释中

步骤:

  • 我使用GetOpenFilename()并浏览有效文件
  • 我使用LoadPicture()成功地将图像文件作为对象获取,因此我知道文件和路径都很好
  • 当我尝试使用Fill.UserPicture()时,出现了错误445。我还尝试将Obj直接馈送到UserPicture(),但得到了相同的结果
这是否告诉我后端功能也缺失了

我可以在这里做些什么来在Excel for MacOS中获得此功能(将图像背景添加到便笺中)

    Filestr = Application.GetOpenFilename()
    Const PicX As Integer = 200
    Dim Scalar As Double
    If Filestr <> "" Then
        
        Set Obj = LoadPicture(Filestr)
        Scalar = Obj.Width / PicX
        Dim Rng As Range, Shp As Shape
        Set Rng = Selection 'Use the currently selected cell
        If Not Rng.Comment Is Nothing Then Rng.Comment.Delete
        Rng.AddComment: Rng.Comment.Text Text:=""
        
        Set Shp = Rng.Comment.Shape
        With Shp
            .Fill.UserPicture Filestr '<<<< ERROR 445 OCCURS HERE >>>>
            .Width = Obj.Width / Scalar
            .Height = Obj.Height / Scalar
        End With
        
    End If
Filestr=Application.GetOpenFilename()
常量PicX为整数=200
双精度标量
如果Filestr“”则
设置Obj=LoadPicture(Filestr)
标量=对象宽度/PicX
尺寸Rng作为范围,Shp作为形状
设置Rng=Selection“使用当前选定的单元格”
如果不是Rng.Comment,则为Rng.Comment.Delete
Rng.AddComment:Rng.Comment.Text文本=“”
设置Shp=Rng.Comment.Shape
小水电
.Fill.UserPicture文件tr'>
.Width=对象宽度/标量
.高度=对象高度/标量
以
如果结束

如果我没有错(我可能错了),但是Excel 2016/19 for Mac不支持
.Shape.Fill.UserPicture
。谢谢,Siddharth。是的,从这篇文章开始,我所做的所有研究似乎都证实了形状中的大多数/许多属性在Excel 2016/19 for Mac中是只读的。