Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Powerpoint Automation, process won't end after Quit()

Powerpoint Automation, process won't end after Quit()

Scheduled Pinned Locked Moved Visual Basic
helpcsharpasp-netwpfwcf
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    T Smooth
    wrote on last edited by
    #1

    I'm trying to do some Powerpoint automation from an ASP.NET page and generate/modify a slide. That piece of the code works fine but when it's all done running and even after I call the Quit() method on the powerpoint application object, POWERPOINT.EXE remains running and eventually this is causing problems. I've googled this extensively and nothing I've found has seemed to help. I really need this to work properly. Here's my relevant code. I don't believe i'm using any Global references and I've even removed the COM reference from my website to use Late Binding instead in hopes that it would solve my problems as mentioned in this MSDN Article: http://support.microsoft.com/default.aspx?scid=kb;en-us;319832 Code: Public Function GenerateDrillDown(ByVal strFileName As String) As Boolean Dim App As Object = Nothing Dim pres As Object = Nothing Dim slide As Object = Nothing Try App = CreateObject("PowerPoint.Application") App.Visible = -1 ' For debugging. Comment this out or set to 0 to keep the application from being visible. pres = App.Presentations.Open("C:\DevProjects\Docs\DrillDown.ppt", 0, -1, -1) slide = pres.Slides(1) ' There's only one slide in this ppt i'm using as the template. slide.Shapes.Item("Text Box 8").TextFrame.TextRange.Text = DecisionTitle ' These are all string variables slide.Shapes.Item("Text Box 13").TextFrame.TextRange.Text = Narrative slide.Shapes.Item("Text Box 14").TextFrame.TextRange.Text = Issues slide.Shapes.Item("Text Box 19").TextFrame.TextRange.Text = Scope If TopicType = 1 Then slide.Shapes.Item("Autoshape 9").TextFrame.TextRange.Text = IDNumber.ToString() slide.Shapes.Item("Autoshape 9").Visible = -1 slide.Shapes.Item("Autoshape 56").Visible = 0 ElseIf TopicType = 2 Then slide.Shapes.Item("Autoshape 56").TextFrame.TextRange.Text = "ST" & IDNumber.ToString() slide.Shapes.Item("Autoshape 56").Visible = -1 slide.Shapes.Item("Autoshape 9").Visible = 0 End If pres.SaveAs(strFilename, 1, 0) Catch ex As Exception Return False Finally ' Most of this is coming from another article I found online to help combat the problem of open references with office automation. GC.Collect() GC.WaitForPendingFinalizers() GC.Collect() ' Intentionally repeated GC.WaitForPendingFinalizers() If Not slide Is Nothing Then Marshal.FinalReleaseComObject(slide) slide = Nothing End If If Not pres Is N

    D 1 Reply Last reply
    0
    • T T Smooth

      I'm trying to do some Powerpoint automation from an ASP.NET page and generate/modify a slide. That piece of the code works fine but when it's all done running and even after I call the Quit() method on the powerpoint application object, POWERPOINT.EXE remains running and eventually this is causing problems. I've googled this extensively and nothing I've found has seemed to help. I really need this to work properly. Here's my relevant code. I don't believe i'm using any Global references and I've even removed the COM reference from my website to use Late Binding instead in hopes that it would solve my problems as mentioned in this MSDN Article: http://support.microsoft.com/default.aspx?scid=kb;en-us;319832 Code: Public Function GenerateDrillDown(ByVal strFileName As String) As Boolean Dim App As Object = Nothing Dim pres As Object = Nothing Dim slide As Object = Nothing Try App = CreateObject("PowerPoint.Application") App.Visible = -1 ' For debugging. Comment this out or set to 0 to keep the application from being visible. pres = App.Presentations.Open("C:\DevProjects\Docs\DrillDown.ppt", 0, -1, -1) slide = pres.Slides(1) ' There's only one slide in this ppt i'm using as the template. slide.Shapes.Item("Text Box 8").TextFrame.TextRange.Text = DecisionTitle ' These are all string variables slide.Shapes.Item("Text Box 13").TextFrame.TextRange.Text = Narrative slide.Shapes.Item("Text Box 14").TextFrame.TextRange.Text = Issues slide.Shapes.Item("Text Box 19").TextFrame.TextRange.Text = Scope If TopicType = 1 Then slide.Shapes.Item("Autoshape 9").TextFrame.TextRange.Text = IDNumber.ToString() slide.Shapes.Item("Autoshape 9").Visible = -1 slide.Shapes.Item("Autoshape 56").Visible = 0 ElseIf TopicType = 2 Then slide.Shapes.Item("Autoshape 56").TextFrame.TextRange.Text = "ST" & IDNumber.ToString() slide.Shapes.Item("Autoshape 56").Visible = -1 slide.Shapes.Item("Autoshape 9").Visible = 0 End If pres.SaveAs(strFilename, 1, 0) Catch ex As Exception Return False Finally ' Most of this is coming from another article I found online to help combat the problem of open references with office automation. GC.Collect() GC.WaitForPendingFinalizers() GC.Collect() ' Intentionally repeated GC.WaitForPendingFinalizers() If Not slide Is Nothing Then Marshal.FinalReleaseComObject(slide) slide = Nothing End If If Not pres Is N

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      "Office application does not quit after automation from Visual Studio .NET client[^]" from Microsoft's Knowledgebase.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups