Reputation: 83
I am creating a LotusScript script which creates an Excel file with embedded objects. But when I come to actually embed the PDF file I get "Unable to get the Add property of the OLEObjects class". Unfortunately Lotusscript can't deal with named arguments, so I have to hand over all arguments in the correct order. Not sure if I might leave out trailing optional arguments.
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
Upvotes: 3
Views: 830
Reputation: 71157
Don't pass an empty string if you mean to "skip" an optional parameter: the function is receiving the empty string and attempting to run with it.
Instead, skip them - placeholder arguments would look like this:
Set oleObj = OLEObjs.Add(, tempdir + "\" + pdfname, False, True, , , pdfname, , , , )
Not sure if I might leave out trailing optional arguments.
I don't know LotusScript, but it's worth a shot. This is legal in VBA, and exactly equivalent to the above:
Set oleObj = OLEObjs.Add(, tempdir + "\" + pdfname, False, True, , , pdfname)
Upvotes: 4