Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / November 2003

Tip: Looking for answers? Try searching our database.

After Applying KB arrticle Still Excel won't quit

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Claudio Benghi - 20 Nov 2003 11:46 GMT
Hello World,

I've found a problem regarding Interop on Excel 2000.

Here's KB article where the problem should be discussed:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;317109

After Applying KB arrticle Still Excel won't quit after subroutine if.

oSheet.Copy(oSheet, )

function is executed.

If I omit the above line from the code everything works fine... any
ideas?
I've read that OXPPIAs have been tested under framework 1.0 and I'm
actually using visual studio 2003 but I cant' revert my project to
2002...

Reproducting behaviour code follows...

Thanks,
    Claudio
------------------------------------
Dim oExcel As Object
Dim oBook As Object
Dim oWbs As Object
Dim oWb As Object
Dim oSheets As Object
Dim oSheet As Object

oExcel = CreateObject("Excel.Application")
oExcel.visible = True
System.Threading.Thread.CurrentThread.Sleep(3000)
oWbs = oExcel.Workbooks
oWb =
oWbs.Open("C:\Bonghi\Ddm\LagDuf\JSR\jsr_dot_net\LD_JSR\Reports\store\1.xls")
oSheets = oWb.sheets
oSheet = oSheets(1)
oSheet.Copy(oSheet, )  ' <--- This line causes Excel task not to quit
oWb.Save()

' NAR sub Taken from KB Article
'
NAR(oSheet)
NAR(oSheets)
NAR(oWb)
NAR(oWbs)
oExcel.quit()
NAR(oExcel)

GC.Collect()
Paul Clement - 20 Nov 2003 15:59 GMT
¤ Hello World,
¤
¤ I've found a problem regarding Interop on Excel 2000.
¤
¤ Here's KB article where the problem should be discussed:
¤ http://support.microsoft.com/default.aspx?scid=kb;EN-US;317109
¤
¤ After Applying KB arrticle Still Excel won't quit after subroutine if.
¤
¤ oSheet.Copy(oSheet, )
¤
¤ function is executed.
¤
¤ If I omit the above line from the code everything works fine... any
¤ ideas?
¤ I've read that OXPPIAs have been tested under framework 1.0 and I'm
¤ actually using visual studio 2003 but I cant' revert my project to
¤ 2002...
¤
¤ Reproducting behaviour code follows...
¤
¤ Thanks,
¤     Claudio
¤ ------------------------------------
¤ Dim oExcel As Object
¤ Dim oBook As Object
¤ Dim oWbs As Object
¤ Dim oWb As Object
¤ Dim oSheets As Object
¤ Dim oSheet As Object
¤
¤ oExcel = CreateObject("Excel.Application")
¤ oExcel.visible = True
¤ System.Threading.Thread.CurrentThread.Sleep(3000)
¤ oWbs = oExcel.Workbooks
¤ oWb =
¤ oWbs.Open("C:\Bonghi\Ddm\LagDuf\JSR\jsr_dot_net\LD_JSR\Reports\store\1.xls")
¤ oSheets = oWb.sheets
¤ oSheet = oSheets(1)
¤ oSheet.Copy(oSheet, )  ' <--- This line causes Excel task not to quit
¤ oWb.Save()
¤
¤ ' NAR sub Taken from KB Article
¤ '
¤ NAR(oSheet)
¤ NAR(oSheets)
¤ NAR(oWb)
¤ NAR(oWbs)
¤ oExcel.quit()
¤ NAR(oExcel)
¤
¤
¤ GC.Collect()

The Copy method call is probably creating an implicit (Worksheet) object reference. Try setting an
object variable to the Copy statement and then use NAR function to destroy that object.

oWorksheet = oSheet.Copy(oSheet, )

'...

NAR(oWorksheet)

Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)
Claudio Benghi - 22 Nov 2003 23:18 GMT
>The Copy method call is probably creating an implicit (Worksheet) object reference. Try setting an
>object variable to the Copy statement and then use NAR function to destroy that object.
[quoted text clipped - 7 lines]
>Paul ~~~ pclement@ameritech.net
>Microsoft MVP (Visual Basic)

Excuse me for answeing this late... I've had some (other) troubles...

Anyway... the copy function just returns a bool.

I suppose it's just success or not.

Any other Idea?

Many thanks for your reply.

Claudio
Paul Clement - 24 Nov 2003 16:44 GMT
¤ On Thu, 20 Nov 2003 09:59:12 -0600, Paul Clement
¤ <UseAdddressAtEndofMessage@swspectrum.com> wrote:
¤ >
¤ >The Copy method call is probably creating an implicit (Worksheet) object reference. Try setting an
¤ >object variable to the Copy statement and then use NAR function to destroy that object.
¤ >
¤ >oWorksheet = oSheet.Copy(oSheet, )
¤ >
¤ >'...
¤ >
¤ >NAR(oWorksheet)
¤ >
¤ >
¤ >Paul ~~~ pclement@ameritech.net
¤ >Microsoft MVP (Visual Basic)
¤
¤ Excuse me for answeing this late... I've had some (other) troubles...
¤
¤ Anyway... the copy function just returns a bool.
¤
¤ I suppose it's just success or not.
¤
¤ Any other Idea?
¤
¤ Many thanks for your reply.
¤
¤ Claudio

It looks to me as if Excel eventually terminates once you close the application. If you need to
repeatedly use Excel automation while the application is running you may want to use GetObject to
return a currently running instance.

Since it appears that Excel is creating an implicit object reference for the new (copied) worksheet
I don't see any way to get at it. For whatever reason the Copy method doesn't return a object
reference, which is contrary to the Excel documentation.

Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.