>I use Excel 2000 as a reporting tool through automation. If a user selects to Preview a Report, I know how to bring it up in the Excel PREVIEW window. When the user closes the Preview window, excel usually reverts to Normal View. Is it possible to close Excel at this point and prevent this behavior so that the user is returned back to the application (VFP) ?
>
>
>Thanks in advance
>
>Fred Matano
When you issue ExcelWorkbook.PrintPreview from VFP application, the latter stops execution and waits for user to close Preview window, either by printing or by returning to 'Normal View'. It means that you can just close Excel from VFP when it regains control, see this example:
oExcel=CREATEOBJECT('Excel.Application')
with oExcel
.Visible=.t.
.Workbooks.Add
.ActiveWorkbook.Sheets(1).Cells(1,1).Value='test'
.ActiveWorkbook.PrintPreview
.DisplayAlerts=.F.
.Quit
endwith
Edward Pikman
Independent Consultant