Worksheet delete using Excel as OLE server 
Author Message
 Worksheet delete using Excel as OLE server

I am working on a program that is supposed to work unattended for a
couple of hours or days (heavy number crunching, ... well, heavy for
my pentium 120 anyway). At one point I use the OLE automation features
of Excel to present some results. When I create a new workbook it is
created with a default number of worksheets and I don't want to change
this user setting in Excel. The thing is, I would like to get rid of
the worksheets I don't need. So I use the call :    

xlwk.Worksheets("sheet1").Delete

 where xlwk is a valid workbook object. Unfortunately, Excel ask for
confirmation of the delete. I tried with setting the parameter
Excel.Application.DisplayAlerts to False but this does not change
anything. I found later in the help that each OLE request is seen as
an individual macro by Excel. When I set DisplayAlerts to false this
macro is executed, but Excel sets it back to true at the end the
execution. So the next macro "Delete" brings again the confirmation
mesage box. ( In other words, it would work in a VBA macro running in
Excel but not with OLE calls from VB.)

So I am stuck, the only solution I can imagine now is to close the
message box with a SendKeys but I would like a "nicer" solution...

I know, I can also live with the excess worksheets but I guess there
must be a solution...

Thanks in advance for any suggestions.

Xavier Colonna de Lega              SWISS FEDERAL INSTITUTE OF
DGC-IMAC-EPFL /Ecublens               TECHNOLOGY, LAUSANNE
CH-1015 Lausanne (Switzerland)



Sat, 16 Jan 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. OLE: Excel worksheet without using Excel

2. How can I open Excel workbook without using Excel.Worksheet

3. deleting worksheet in excel workbook

4. Deleting Rows Across Multiple Excel Worksheets

5. Can't delete record from Excel Worksheet

6. VBasic macro to delete worksheet from within Excel

7. Deleting a created Excel worksheet in VB...

8. Delete a row in Excel worksheet from VB program

9. Delete Excel Worksheet With ADO

10. Saving Excel Worksheet in DB as OLE Object

11. Excel Worksheet Via OLE - Problem

12. Problem sizing Excel worksheet in OLE Container on VB form

 

 
Powered by phpBB® Forum Software