Saving an Excel file with Lotus Script-Instance member saveas does not exist

I am sure somebody out there will find the below totally obvious but it has got me confused.

Having successfully exported the contents of a view to an excel spreadsheet with a Lotus script agent and populated the spreadsheet as I want it the spreadsheet is open but does not save. However I want the thing to save onto a harddrive using the same agent to compleet the job. Then I can pick it up an attach it to a Notes Document in another database.

I have been looking in OLE reference library without success.

I tried the following:

......	Set xlApp = CreateObject("Excel.Application")

xlApp.Visible = False

Set xlWkBook = xlApp.Workbooks..............



'Save the excel file

Dim cfilename As Variant

Dim tst As Variant

cfilename=Environ("temp")"

tst=Dir(cfilename,16)

If tst=" " Then Mkdir(cfilename)

cfilename=cfilename & "\NABExport.csv"





Call xlwkbook.Saveas(cfilename)

Saveas, Save, and Saveascopy are all methods that go with the workbook according to the library but I get the error that.

“Instance member saveas does not exist”

I have tried with strings and variants.

What am I doing wrong here?

Subject: Saving an Excel file with Lotus Script-Instance member saveas does not exist

Try replacing this:

Set xlWkBook = xlApp.Workbooks

with this

Set xlWkBook = xlApp.ActiveWorkbook

Your code is pointing to the workbooks COLLECTION; save methods are called on an individual workbook.

Subject: RE: Saving an Excel file with Lotus Script-Instance member saveas does not exist

Yes that works now- You star!!! - thanks :slight_smile: