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.