Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel Automation VS.NET2003

after objExcel.Quit I would have

objWorkbook = Nothing
objWorkbooks = Nothing
objExcel = Nothing

or the .Net equivalent.



--
Regards,
Tom Ogilvy


"Jeff Grundy" wrote in 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.







  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel Automation VS.NET2003

In vb.6 that works. But in .net the Object Lifetime is
different. I also tried GC.Collect after the
objExcel.Quit.

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/vbcn7/html/vaconFinalizeDestructors.asp


-----Original Message-----
after objExcel.Quit I would have

objWorkbook = Nothing
objWorkbooks = Nothing
objExcel = Nothing

or the .Net equivalent.



--
Regards,
Tom Ogilvy


"Jeff Grundy" wrote in 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.







.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel Automation VS.NET2003

This example shows them releasing the variables:

http://support.microsoft.com/default...b;en-us;303871

and this one
http://support.microsoft.com/default...b;en-us;303294

and this one
http://support.microsoft.com/default...b;en-us;302094

and here again:

http://support.microsoft.com/default...b;en-us;301982
HOWTO: Automate Microsoft Excel from Visual Basic .NET

but may be this one has the answer:

http://support.microsoft.com/default...b;en-us;317109
PRB: Office Application Does Not Quit After Automation from Visual Studio
..NET Client

--
Regards,
Tom Ogilvy



"Jeff Grundy" wrote in message
...
In vb.6 that works. But in .net the Object Lifetime is
different. I also tried GC.Collect after the
objExcel.Quit.

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/vbcn7/html/vaconFinalizeDestructors.asp


-----Original Message-----
after objExcel.Quit I would have

objWorkbook = Nothing
objWorkbooks = Nothing
objExcel = Nothing

or the .Net equivalent.



--
Regards,
Tom Ogilvy


"Jeff Grundy" wrote in 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.







.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel Automation VS.NET2003

System.Runtime.InteropServices.Marshal.ReleaseComO bject is
the answer.

Thank you

-----Original Message-----
This example shows them releasing the variables:

http://support.microsoft.com/default.aspx?scid=kb;en-

us;303871

and this one
http://support.microsoft.com/default.aspx?scid=kb;en-

us;303294

and this one
http://support.microsoft.com/default.aspx?scid=kb;en-

us;302094

and here again:

http://support.microsoft.com/default.aspx?scid=kb;en-

us;301982
HOWTO: Automate Microsoft Excel from Visual Basic .NET

but may be this one has the answer:

http://support.microsoft.com/default.aspx?scid=kb;en-

us;317109
PRB: Office Application Does Not Quit After Automation

from Visual Studio
..NET Client

--
Regards,
Tom Ogilvy



"Jeff Grundy" wrote in message
...
In vb.6 that works. But in .net the Object Lifetime is
different. I also tried GC.Collect after the
objExcel.Quit.

http://msdn.microsoft.com/library/default.asp?
url=/library/en-

us/vbcn7/html/vaconFinalizeDestructors.asp


-----Original Message-----
after objExcel.Quit I would have

objWorkbook = Nothing
objWorkbooks = Nothing
objExcel = Nothing

or the .Net equivalent.



--
Regards,
Tom Ogilvy


"Jeff Grundy" wrote in 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.







.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Excel with automation Thomas Bodell Excel Discussion (Misc queries) 5 May 8th 09 03:09 PM
Excel spradsheet automation help deepika New Users to Excel 1 January 4th 08 06:22 PM
Vb.net - excel 97 automation michael Excel Programming 0 August 14th 03 06:16 PM
XLL - VS .Net2003 - init problem - const char strings - /Gf option?? Kevin Love Excel Programming 0 July 27th 03 11:32 PM
XLL - VS .Net2003 - init problem - const char strings - /Gf option?? Rob Bovey Excel Programming 1 July 27th 03 10:41 PM


All times are GMT +1. The time now is 09:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"