Excel 运行时错误 "Unable to get the add property of the OLEObjects class"

Excel Runtime Error "Unable to get the add property of the OLEObjects class"

我正在创建一个 LotusScript 脚本,该脚本创建一个 Excel 带有嵌入式对象的文件。但是当我真正嵌入 PDF 文件时,我得到 "Unable to get the Add property of the OLEObjects class"。 不幸的是,Lotusscript 无法处理命名参数,所以我必须以正确的顺序交出所有参数。不确定我是否可以省略尾随的可选参数。

tempdir = "c:\data\temp"
pdfname = "20140826-32051-1890459257-300-421425-GRF.pdf"
Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Add
Set xlsheet = xlApp.Workbooks(1).Worksheets(1)
Set oleObjs = xlsheet.OLEObjects
Set oleObj = OLEObjs.Add("", tempdir + "\" + pdfname, False, _
True, "", "", pdfname, _
"","","","")
'Arguments: ClassType, FileName, Link,
'DisplayAsIcon, IconFileName, IconIndex, IconLabel,
'Left, Top, Width, Height

如果您要 "skip" 一个可选参数,请不要传递空字符串:该函数正在接收空字符串并尝试 运行 使用它。

相反,跳过它们 - 占位符参数将如下所示:

Set oleObj = OLEObjs.Add(, tempdir + "\" + pdfname, False, True, , , pdfname, , , , )

Not sure if I might leave out trailing optional arguments.

我不了解 LotusScript,但值得一试。这在VBA中是合法的,并且完全等同于上面的:

Set oleObj = OLEObjs.Add(, tempdir + "\" + pdfname, False, True, , , pdfname)