Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel Automation in VB
Message
 
À
16/05/2003 14:22:58
Information générale
Forum:
Visual Basic
Catégorie:
COM, DCOM et OLE automation
Divers
Thread ID:
00789379
Message ID:
00789699
Vues:
19
Have you tried setting your worksheet object to nothing also?


>I have a VB app that creates an Excel 97 file. After the file is created I save it, close the application object and set it to nothing. However, if I look in Task Manager, Excel remains open until I completely exit the VB app. What do I need to change? Below is the code for how I create the Excel object and close it in a Class Module:
>
>'Objects Required for Excel
>Private m_objExcel As Excel.Application
>Private m_objWrkbk As Excel.Workbook
>Private m_objWrkSht As Excel.Worksheet
>
>Public Sub CreateFile()
>
>'Initialize the Excel 97 object
>Set m_objExcel = CreateObject("Excel.Application.8")
>
>'I've found that if I do not minimize the app I often get an
>'Error stating app is busy "Switch or Retry" and the program fails
>m_objExcel.WindowState = xlMinimized
>
>'Add the Workbook to the Excel object
>Set m_objWrkbk = m_objExcel.Workbooks.Add
>
>'Sometimes need more then 1 worksheet so I got into the
>'habit of always adding one
>Set m_objWrkSht = m_objWrkbk.Worksheets.Add
>
>'Rename the worksheet
>m_objWrkSht.Activate
>m_objWrkSht.name = "Problem Loan Summary"
>
>'Code to Enter data into the worksheet goes here
>
>'Close the Workbook
>m_objWrkbk.Close True, "c:\test.xls"
>
>'Release workbook from memory
>Set m_objWrkbk = Nothing
>
>'Close the Excel object
>m_objExcel.Quit
>
>'Release Excel Object from Memory
>Set m_objExcel = Nothing
>
>End Sub
>
>----------End of Code -----------------------------
>
>At this point I would expect the Excel application to be done and not showing in Task Manager. What step am I missing?
>
>Thanks
>
>Nichole
É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