Home All Groups Group Topic Archive Search About

Office application object problem

Author
4 Oct 2006 10:22 AM
sajin
Hi all,

I'am trying to create object of Excel and powerpoint through my VB.Net
2005 application. When user close the excel or powerpoint it's instance

remains in the task manager.
I used ReleaseComObject because of which excel instance now goes trough
task manager , but same dosen't work with the Powerpoint object.
Any solution?
- Thanks
-Sajin

Author
4 Oct 2006 10:42 AM
Robinson
Show quote Hide quote
"sajin" <sa***@iprlab.com> wrote in message
news:1159957365.831373.112150@e3g2000cwe.googlegroups.com...
> Hi all,
>
> I'am trying to create object of Excel and powerpoint through my VB.Net
> 2005 application. When user close the excel or powerpoint it's instance
>
> remains in the task manager.
> I used ReleaseComObject because of which excel instance now goes trough
> task manager , but same dosen't work with the Powerpoint object.
> Any solution?
> - Thanks
> -Sajin
>

A simple test would be to create a new project, create two simple objects -
one Powerpoint instance, one Excel instance, release them and see if they
still hang around.  I think that probably they will dissapear from Task
Manager.  I suspect you have a reference to an instance of an object
returned from Powerpoint still loitering in your run somewhere.  Are you
calling any methods on the office objects that return objects (like fields,
or selections or suchlike)?  Those are reference counted and also need to be
released, not just the application instances.



Robin
Author
4 Oct 2006 12:59 PM
sajin
Hi,
After doing ReleaseCom also still the instance exists in the task
manager , this is the code i am using
***********************************************************************************
Dim filepath As String

        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK
Then
            filepath = OpenFileDialog1.FileName
        End If

        PowerApp = New PowerPoint.Application

        PowerApp.Visible = Office.MsoTriState.msoCTrue

        PowerApp.Presentations.Open(filepath,
Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse,
Office.MsoTriState.msoTrue)

PowerApp.ActiveWindow.View.GotoSlide(index:=PowerApp.ActivePresentation.Slides.Add(index:=1,
Layout:=PowerPoint.PpSlideLayout.ppLayoutTitle).SlideIndex)
        ' only close PowerPoint if there are no open Presentations
        If (PowerApp.Presentations.Count <= 0) Then
            PowerApp.Quit()
        End If

***********************************************************************************

Robinson wrote:
Show quoteHide quote
> "sajin" <sa***@iprlab.com> wrote in message
> news:1159957365.831373.112150@e3g2000cwe.googlegroups.com...
> > Hi all,
> >
> > I'am trying to create object of Excel and powerpoint through my VB.Net
> > 2005 application. When user close the excel or powerpoint it's instance
> >
> > remains in the task manager.
> > I used ReleaseComObject because of which excel instance now goes trough
> > task manager , but same dosen't work with the Powerpoint object.
> > Any solution?
> > - Thanks
> > -Sajin
> >
>
> A simple test would be to create a new project, create two simple objects -
> one Powerpoint instance, one Excel instance, release them and see if they
> still hang around.  I think that probably they will dissapear from Task
> Manager.  I suspect you have a reference to an instance of an object
> returned from Powerpoint still loitering in your run somewhere.  Are you
> calling any methods on the office objects that return objects (like fields,
> or selections or suchlike)?  Those are reference counted and also need to be
> released, not just the application instances.
>
>
>
> Robin
Author
4 Oct 2006 12:59 PM
sajin
Hi,
After doing ReleaseCom also still the instance exists in the task
manager , this is the code i am using
***********************************************************************************
Dim filepath As String

        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK
Then
            filepath = OpenFileDialog1.FileName
        End If

        PowerApp = New PowerPoint.Application

        PowerApp.Visible = Office.MsoTriState.msoCTrue

        PowerApp.Presentations.Open(filepath,
Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse,
Office.MsoTriState.msoTrue)

PowerApp.ActiveWindow.View.GotoSlide(index:=PowerApp.ActivePresentation.Slides.Add(index:=1,
Layout:=PowerPoint.PpSlideLayout.ppLayoutTitle).SlideIndex)
        ' only close PowerPoint if there are no open Presentations
        If (PowerApp.Presentations.Count <= 0) Then
            PowerApp.Quit()
        End If

***********************************************************************************

Robinson wrote:
Show quoteHide quote
> "sajin" <sa***@iprlab.com> wrote in message
> news:1159957365.831373.112150@e3g2000cwe.googlegroups.com...
> > Hi all,
> >
> > I'am trying to create object of Excel and powerpoint through my VB.Net
> > 2005 application. When user close the excel or powerpoint it's instance
> >
> > remains in the task manager.
> > I used ReleaseComObject because of which excel instance now goes trough
> > task manager , but same dosen't work with the Powerpoint object.
> > Any solution?
> > - Thanks
> > -Sajin
> >
>
> A simple test would be to create a new project, create two simple objects -
> one Powerpoint instance, one Excel instance, release them and see if they
> still hang around.  I think that probably they will dissapear from Task
> Manager.  I suspect you have a reference to an instance of an object
> returned from Powerpoint still loitering in your run somewhere.  Are you
> calling any methods on the office objects that return objects (like fields,
> or selections or suchlike)?  Those are reference counted and also need to be
> released, not just the application instances.
>
>
>
> Robin
Author
4 Oct 2006 2:15 PM
Robinson
>
> PowerApp.ActiveWindow.View.GotoSlide(index:=PowerApp.ActivePresentation.Slides.Add(index:=1,
> Layout:=PowerPoint.PpSlideLayout.ppLayoutTitle).SlideIndex)
>        ' only close PowerPoint if there are no open Presentations
>        If (PowerApp.Presentations.Count <= 0) Then
>            PowerApp.Quit()
>        End If
>

Don't quote me but I think possibly PowerApp.ActivePresentation.Slides is a
reference.  Try fetching the reference (PowerApp.ActivePresentation.Slides)
into a variable and then issuing the Add in a new statement, then releasing
the variable you allocated for the Slides collection.  Also be aware if Add
returns a reference (I don't think it does, but just in case).  You should
be very wary of compound statements like this when using interop, because
sometime references are created that you don't see very easily.
Author
4 Oct 2006 3:05 PM
Peter Proost
Hi when I use a word object I always "dispose" of it like this and then
nothing remains in the taskmanager

'open word class
Dim oWord As New Word.ApplicationClass

'open a document
Dim oDoc As Word.Document

'add a template to it
oDoc = oWord.Documents.Add(Application.StartupPath & "\yourfile.dot")

'do the work
....

'release eveything
oDoc.Close()
oDoc = Nothing
oWord.Quit(False)
oWord = Nothing


hope this helps,

Greetz, Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Robinson" <toomuchspamhaspassed@myinboxtoomuchtoooften.com> schreef in
bericht news:eg0flv$6pt$1$8302bc10@news.demon.co.uk...
> >
> >
PowerApp.ActiveWindow.View.GotoSlide(index:=PowerApp.ActivePresentation.Slid
es.Add(index:=1,
> > Layout:=PowerPoint.PpSlideLayout.ppLayoutTitle).SlideIndex)
> >        ' only close PowerPoint if there are no open Presentations
> >        If (PowerApp.Presentations.Count <= 0) Then
> >            PowerApp.Quit()
> >        End If
> >
>
> Don't quote me but I think possibly PowerApp.ActivePresentation.Slides is
a
> reference.  Try fetching the reference
(PowerApp.ActivePresentation.Slides)
Show quoteHide quote
> into a variable and then issuing the Add in a new statement, then
releasing
> the variable you allocated for the Slides collection.  Also be aware if
Add
> returns a reference (I don't think it does, but just in case).  You should
> be very wary of compound statements like this when using interop, because
> sometime references are created that you don't see very easily.
>
>
>
>
>
>