ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
Go Back  Xtreme Visual Basic Talk > > > ASP.NET Powerpoint Automation


Reply
 
Thread Tools Display Modes
  #1  
Old 03-09-2005, 03:35 AM
White Eagle White Eagle is offline
Newcomer
 
Join Date: Mar 2005
Posts: 3
Question ASP.NET Powerpoint Automation


I have two problems. I am using Powerpoint to generate a presentation in ASP.NET which works, but:
(a) Why do I have to use impersonation? Can it be done without impersonation?
(b) The Powerpoint instance is still running even after I close the browser. How can I make sure the Powerpoint process closes down?

The code is as follows:
Code:
' Link button on webform that generates the Powerpoint file Private Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click Dim oReport As New clsService() oReport.TestPPt() oReport = Nothing End Sub ' Class used to generate Powerpoint file Public Class clsService Private m_oPowerpoint As PowerPoint.Application Private m_oPresentation As PowerPoint.Presentation Public Function TestPPt() Dim cI As clsImpersonate cI = New clsImpersonate() ' Impersonate cI.ImpersonateUser("user1", "DEVELOPMENT", "pwd1") m_oPowerpoint = New PowerPoint.Application() m_oPresentation = m_oPowerpoint.Presentations.Open _ ("c:\Templates\mytemplate.pot", Office.MsoTriState.msoFalse, _ Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse) ' ..... m_oPresentation.Saved = True m_oPresentation.Close() m_oPresentation = Nothing m_oPowerpoint.Quit() m_oPowerpoint = Nothing GC.Collect() cI.UndoImpersonate() End Function End Class

Last edited by herilane; 03-09-2005 at 05:36 AM. Reason: [vb] tags make your code easier to read
Reply With Quote
  #2  
Old 03-09-2005, 05:53 AM
herilane's Avatar
herilaneASP.NET Powerpoint Automation herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default

(a)
It may be possible to do it without impersonation, but it may actually be cleaner to stick to impersonation.

The issue here is that Office apps were not made for server-side automation. They assume that they are run by a user, so they try to load user settings from the registry, initialize toolbars, connect to printers, load add-ins, etc etc. Your ASPNET account probably doesn't have the required access rights for most of that. So if you don't want to use impersonation, you'll have to change the settings for the ASPNET account.

MSDN KB articles:
http://support.microsoft.com/kb/257757
http://support.microsoft.com/kb/288368

(b)
You probably have an unqualified reference to a Powerpoint object somewhere in the code that you didn't post. That's by far the most common reason for these problems. If you could post your code, we can help you track it down.
Reply With Quote
  #3  
Old 03-09-2005, 06:34 AM
White Eagle White Eagle is offline
Newcomer
 
Join Date: Mar 2005
Posts: 3
Default

I have replaced all the code indicated by '....' so that all it is doing is opening a presentation and then closing it again. Still the Powerpoint process remains alive.
Reply With Quote
  #4  
Old 03-09-2005, 06:38 AM
herilane's Avatar
herilaneASP.NET Powerpoint Automation herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default

Let's simplify the problem for a moment, by getting rid of the server-side automation part of it. If you run the same PP automation code locally, from a VB.Net app (minus the impersonation part), does it work properly? (I don't have VB.Net at work so I can't test this myself right now, sorry.)
Reply With Quote
  #5  
Old 03-09-2005, 07:11 AM
White Eagle White Eagle is offline
Newcomer
 
Join Date: Mar 2005
Posts: 3
Default

Yes it does.
Reply With Quote
  #6  
Old 03-09-2005, 09:25 AM
herilane's Avatar
herilaneASP.NET Powerpoint Automation herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default

Hmmm... that's odd. Unfortunately I don't do any web programming myself, and our web programming experts rarely dabble in Office, so if the problem only occurs in server-side automation, our chances of finding a fix are quite low...

Try the remedies suggested here:
http://support.microsoft.com/default...B;EN-US;317109
I was mainly thinking of the part about referencing one object at a time. So:
Code:
m_oPresentation = m_oPowerpoint.Presentations.Open strFileName 'would become Dim m_oPresentations As PowerPoint.Presentations Dim m_oPresentation As PowerPoint.Presentation m_oPresentations = m_oPowerpoint.Presentations m_oPresentation = m_oPresentations.Open strFileName
If that still doesn't solve the problem, then I'm out of ideas, and can only suggest killing the PP process when you're done.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
 
ASP.NET Powerpoint Automation
ASP.NET Powerpoint Automation
 
-->