Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Re: Nameless Excel Spreadsheet
Message
From
05/11/2002 16:43:30
 
 
To
05/11/2002 10:38:32
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00718854
Message ID:
00719071
Views:
18
This message has been marked as the solution to the initial question of the thread.
Hilmar,

PMFJI, below is an extract from a class that does exactly this. Basically, the generated Excel sheet is copied using the Copy method and the original workbook is closed. In my case, I delete the temp file and leave it up to the user to save or discard the generated Excel file. If you want to keep the original file, simply comment the DELETE FILE line.
oXLS = CREATEOBJECT("Excel.Application")
loWkBk = oXLS.Application.Workbooks.Open(lcExcelFile)

oXls.Application.DisplayAlerts = .f.

*-- add a new workbook
loWkBkTmp = oXls.workbooks.Add()
*-- copy the created worksheet to the new workbook
loWkBk.ActiveSheet.Copy(loWkBkTmp.Sheets(1))
*-- close the original workbook
loWkBk.Close()

*-- we can now safely delete the Excel file from disk
This.ioApi.sleep(500)

IF FILE(lcExcelFile)
   DELETE FILE (lcExcelFile)
ENDIF

*-- it's important to set displayAlerts on, otherwise the user won't
*-- be reminded to save the Excel file when quitting.
oXls.Application.DisplayAlerts = .t.

*-- display Excel file. It's now up to the user to save or discard the
*-- Excel file...
oXls.visible = .t.
HTH
>>If the sheets are not large, you might want to think about using Excel automation to populate and name the sheet for you; put the data into your XLS spreadsheet, open a new workbook using automation, and then copy the XLS (or DBF - Excel can read a DBF file) into the proper cells, or open the XLS you create using automation and then rename it via Save As before exposing it to the user to edit.
>
>The problem here is that the "Save" command still won't be disabled - I only want the user to have access to the file to have a filename - IOW, if the user presses "Save", I want the "SaveAs" dialog to appear; I do not want the user to overwrite some temporary filename.
>
>I was looking for some "Insert from File" command, but this seems to be available only in MS-Word, not in Excel.
>
>Hilmar.
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform