|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Office application object problemHi 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
Show quote
Hide quote
"sajin" <sa***@iprlab.com> wrote in message A simple test would be to create a new project, create two simple objects - 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 > 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 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 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 > Don't quote me but I think possibly PowerApp.ActivePresentation.Slides is a > 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 > 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. 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 PowerApp.ActiveWindow.View.GotoSlide(index:=PowerApp.ActivePresentation.Slidbericht news:eg0flv$6pt$1$8302bc10@news.demon.co.uk... > > > > es.Add(index:=1, > > Layout:=PowerPoint.PpSlideLayout.ppLayoutTitle).SlideIndex) (PowerApp.ActivePresentation.Slides)> > ' 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 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. > > > > > >
You're good if you can answer this one.....
.NET 2 recommended books? Sending email with attachments Open folders to process files automatically Datetimepicker - just getting the data part ComboBox.Items.Clear() How to convert code snipped from VB6 to Visual Studio 2005/VB (VB7?) Changing Printer's default paper Extracting icon from file: most efficient method? Does a menu item lose dataset information? |
|||||||||||||||||||||||