Office application object problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sajin

    #1

    Office application object problem

    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 ReleaseComObjec t because of which excel instance now goes trough
    task manager , but same dosen't work with the Powerpoint object.
    Any solution?
    - Thanks
    -Sajin

  • Robinson

    #2
    Re: Office application object problem


    "sajin" <sajin@iprlab.c omwrote in message
    news:1159957365 .831373.112150@ e3g2000cwe.goog legroups.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 ReleaseComObjec t 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


    Comment

    • sajin

      #3
      Re: Office application object problem

      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.D ialogResult.OK
      Then
      filepath = OpenFileDialog1 .FileName
      End If

      PowerApp = New PowerPoint.Appl ication

      PowerApp.Visibl e = Office.MsoTriSt ate.msoCTrue

      PowerApp.Presen tations.Open(fi lepath,
      Office.MsoTriSt ate.msoFalse, Office.MsoTriSt ate.msoFalse,
      Office.MsoTriSt ate.msoTrue)

      PowerApp.Active Window.View.Got oSlide(index:=P owerApp.ActiveP resentation.Sli des.Add(index:= 1,
      Layout:=PowerPo int.PpSlideLayo ut.ppLayoutTitl e).SlideIndex)
      ' only close PowerPoint if there are no open Presentations
      If (PowerApp.Prese ntations.Count <= 0) Then
      PowerApp.Quit()
      End If

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

      Robinson wrote:
      "sajin" <sajin@iprlab.c omwrote in message
      news:1159957365 .831373.112150@ e3g2000cwe.goog legroups.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 ReleaseComObjec t 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

      Comment

      • sajin

        #4
        Re: Office application object problem

        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.D ialogResult.OK
        Then
        filepath = OpenFileDialog1 .FileName
        End If

        PowerApp = New PowerPoint.Appl ication

        PowerApp.Visibl e = Office.MsoTriSt ate.msoCTrue

        PowerApp.Presen tations.Open(fi lepath,
        Office.MsoTriSt ate.msoFalse, Office.MsoTriSt ate.msoFalse,
        Office.MsoTriSt ate.msoTrue)

        PowerApp.Active Window.View.Got oSlide(index:=P owerApp.ActiveP resentation.Sli des.Add(index:= 1,
        Layout:=PowerPo int.PpSlideLayo ut.ppLayoutTitl e).SlideIndex)
        ' only close PowerPoint if there are no open Presentations
        If (PowerApp.Prese ntations.Count <= 0) Then
        PowerApp.Quit()
        End If

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

        Robinson wrote:
        "sajin" <sajin@iprlab.c omwrote in message
        news:1159957365 .831373.112150@ e3g2000cwe.goog legroups.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 ReleaseComObjec t 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

        Comment

        • Robinson

          #5
          Re: Office application object problem

          >
          PowerApp.Active Window.View.Got oSlide(index:=P owerApp.ActiveP resentation.Sli des.Add(index:= 1,
          Layout:=PowerPo int.PpSlideLayo ut.ppLayoutTitl e).SlideIndex)
          ' only close PowerPoint if there are no open Presentations
          If (PowerApp.Prese ntations.Count <= 0) Then
          PowerApp.Quit()
          End If
          >
          Don't quote me but I think possibly PowerApp.Active Presentation.Sl ides is a
          reference. Try fetching the reference (PowerApp.Activ ePresentation.S lides)
          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.






          Comment

          • Peter Proost

            #6
            Re: Office application object problem

            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.Applicatio nClass

            'open a document
            Dim oDoc As Word.Document

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

            'do the work
            ....

            'release eveything
            oDoc.Close()
            oDoc = Nothing
            oWord.Quit(Fals e)
            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" <toomuchspamhas passed@myinboxt oomuchtoooften. comschreef in
            bericht news:eg0flv$6pt $1$8302bc10@new s.demon.co.uk.. .
            PowerApp.Active Window.View.Got oSlide(index:=P owerApp.ActiveP resentation.Sli d
            es.Add(index:=1 ,
            Layout:=PowerPo int.PpSlideLayo ut.ppLayoutTitl e).SlideIndex)
            ' only close PowerPoint if there are no open Presentations
            If (PowerApp.Prese ntations.Count <= 0) Then
            PowerApp.Quit()
            End If
            >
            Don't quote me but I think possibly PowerApp.Active Presentation.Sl ides is
            a
            reference. Try fetching the reference
            (PowerApp.Activ ePresentation.S lides)
            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.
            >
            >
            >
            >
            >
            >

            Comment

            Working...