Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Automating Excel
Message
Information générale
Forum:
Visual Basic
Catégorie:
COM, DCOM et OLE automation
Divers
Thread ID:
00516687
Message ID:
00516738
Vues:
17
>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"?

1. Because you Quit. You must leave it open and close it only when you exit the application.
2. Because one object stay instantiate.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform