Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Automating Excel
Message
 
 
À
Tous
Information générale
Forum:
Visual Basic
Catégorie:
COM, DCOM et OLE automation
Titre:
Automating Excel
Divers
Thread ID:
00516687
Message ID:
00516687
Vues:
48
I have a routine that creates an Excel spreadsheet in code but have run into few problems. First, here's some code I'm using:
    Dim excelApp As excel.Application
    Dim excelBook As excel.Workbook
    Dim excelSheet As excel.Worksheet
    
    Set excelApp = GetObject(, "Excel.Application")
    If Err.Number <> 0 Then
         Set excelApp = CreateObject("Excel.Application")
    End If
    
    
    *** some code here to add some data ****


    excelApp.Application.Visible = True
    DoEvents
    excelBook.SaveAs "C:\TEST.XLS"
    excelApp.Quit
    
    Set excelSheet = Nothing
    Set excelBook = Nothing
    Set excelApp = Nothing
My problems:
1. When I run the app, Excel flashes briefly and disappears. How do I make it stay visible so that the user can work with it?
2. It appears this instance of Excel is kept alive (although not visible) with the newly created file open. Therefore, I can't reopen the file until I "kill" the instance of "Excel" running via Task Manager. Why isn't it killed when I set the object ref to "Nothing"?

TIA.
It's "my" world. You're just living in it.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform