Board index » delphi » Workbooks.close AAAAAArgh !

Workbooks.close AAAAAArgh !

 deletefile('c:\meditrac projects\ainsworth\Print.xls');
    sheet:=createoleobject('Excel.Application.8');
    sheet.Workbooks.open('c:\meditrac
projects\Venalink\Methatrac\Prison.xls');
    sheet.activeWorkbook.saveas('c:\meditrac
projects\ainsworth\Print.xls');
    sheet.Run('Print.xls!Macro1');
    sheet.Workbooks('c:\meditrac
projects\ainsworth\Print.xls').Close.SaveChanges:=False;
    Sheet.Quit;
    sheet:='';

The Close bit always gives member not found. I can use close without
specifying filename and savechanges but then dialog box save or not
appears

AAAAAAAAAAAArgh

How do I close without saving and no Dialog Box

 

Re:Workbooks.close AAAAAArgh !


I've seen the problem myself, and others have had related problems.
You are using an Collection from VBA, nl WorkBooks. Collection in Delphi
behave sligtly different.

In VBA Collection members can be approached in 2 ways
1. WorkBooks("filename").Close  // wich is most used.
2. WorkBooks.Item("filename").Close  // wich is the most proper version.

The point is that in VBA Item is the default property. Delphi won't
support this.

You can't use syntax 1. in Delphi
Use WorkBooks.Item('filename').Close instead.

I've found out about this when looking at the imported typelib.

Edwin Teisman teis...@defacto.nl

Quote
Tim Bugg wrote:

>  deletefile('c:\meditrac projects\ainsworth\Print.xls');
>     sheet:=createoleobject('Excel.Application.8');
>     sheet.Workbooks.open('c:\meditrac
> projects\Venalink\Methatrac\Prison.xls');
>     sheet.activeWorkbook.saveas('c:\meditrac
> projects\ainsworth\Print.xls');
>     sheet.Run('Print.xls!Macro1');
>     sheet.Workbooks('c:\meditrac
> projects\ainsworth\Print.xls').Close.SaveChanges:=False;
>     Sheet.Quit;
>     sheet:='';

> The Close bit always gives member not found. I can use close without
> specifying filename and savechanges but then dialog box save or not
> appears

> AAAAAAAAAAAArgh

> How do I close without saving and no Dialog Box

Other Threads