View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Gillian G. Gillian G. is offline
external usenet poster
 
Posts: 1
Default Excel Automation VS.NET2003

I am having the same issue but while running from a code
module in Access2000. It wont close down the original
excel instance i create in code.

xlWorkSheet.Close
Set xlWorkSheet = Nothing
Set xlWorkBook = Nothing

xlApp.Quit
Set xlApp = Nothing

after this the instance is still visible in the process
list but no longer available (hidden). all my references
to the application have gone out of scope.


curious note* i create a workbook from a template with
this line...
Set xlWorkBook = Excel.Workbooks.Add(sDataDir + "\Site
Summary.xlt")
and save it with this line...
Call xlWorkBook.SaveAs(sExportFile)

if i dont create a workbook from a template it exits fine
but i dont get to use my template or save it.

any ideas?

-----Original Message-----
When I create a Windows Forms Application using

VB.NET2003
and have that application create and save a workbook, I
cannot open the worksheet with Excel until I close the VB
application.

Steps to reproduce the problem.

1 Create a Windows Forms Application.

2 Add a reference to 'Microsoft Excel 9.0 Object Library'.

3 Add a command button to Form1 (Button1).

4 Add the following code to the form:

'***Begin Code***
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click

Dim objExcel As Excel.Application
Dim objWorkbook As Excel.Workbook
Dim objWorkbooks As Excel.Workbooks

objExcel = New Excel.Application
objWorkbooks = objExcel.Workbooks
objWorkbook = objWorkbooks.Add

objWorkbook.SaveAs("C:\TempWorkbook.xls")

objExcel.Quit()

End Sub
'***End Code***

5 Run the program.

6 Click the button 1 time.

7 In windows explorer double click the file
C:\TempWorkbook.xls. At this point Excel opens but the
grid area does not display correctly.

8 Close excel.

9 Close the VB application by clicking the x button in

the
corner of form1. If you click 'Stop Debugging' in the IDE
an Excel process will continue to run in Task Manager-
Processes Tab. You need to 'End Process' or rebbot to get
rid of it.

10 In windows explorer double click the file
C:\TempWorkbook.xls. At this point Excel opens the file
correctly.





.