I am creating an Excel spreadsheet through a LotusScript agent and embedding it on a form:
Creating the Excel Object:
Set excelApp = CreateObject(“Excel.Application”)
excelApp.DisplayAlerts = False
excelApp.Visible = False
Set excelNewWkbk = excelApp.Workbooks.Add
Set excelSheet = excelNewWkbk.ActiveSheet
Saving the Excel Object:
Call excelNewWkbk.SaveAs(fileName)
Embedding the Object:
Set embedItem = New NotesRichTextItem(doc, “bl_Sheet”)
Set embedObject = embedItem.EmbedObject(EMBED_OBJECT, “”, fileName)
Each time I attempt to open the embedded object on the Notes document, I receive:
“This document is read-only. If you make any changes in the OLE object they cannot be saved because the document is read-only.”
The Notes document itself is in edit mode and does not have any Reader/Author fields on it.
So, I turned my attention to the embedded object being in read-only mode — the SaveAs method. I recorded a macro in Excel and pulled into my agent – there is a parameter when using the SaveAs method called “ReadOnlyRecommended,” which is set to False:
ActiveWorkbook.SaveAs Filename:=“C:\myDoc.xls”, FileFormat:=xlNormal, Password:=“”, WriteResPassword:=“”, ReadOnlyRecommended:=False, CreateBackup:=False
I tried these 3 ideas for using the SaveAs method (vbNormal = 0):
-
Call excelNewWkbk.SaveAs(fileName, vbNormal, Null, Null, False, False)
-
Call excelNewWkbk.SaveAs(fileName, vbNormal, , , False, False)
-
Call excelNewWkbk.SaveAs(fileName, vbNormal, “”, “”, False, False)
Each returned with:
“Error (213): Microsoft Excel: SaveAs method of workbook class failed.”
Is it how I open/create the Workbook? Is there a parameter to set to editable and not read-only?
Do I have to close the excelApp object after saving the spreadsheet, then open and use the SetFileAttr method in LotusScript (vbNormal = 0):
fileNum% = Freefile()
Open fileName For Output As fileNum%
Close fileNum%
Setfileattr fileName, vbNormal
I have found a few threads on this issue, some good ideas, but not the solution for me:
http://www-10.lotus.com/ldd/46dom.nsf/DateAllFlatweb/dc09168723293c9885256b9e004dd58b?OpenDocument
Any help would be great…
Thanks,
Dan