Accessing Powerpoint

W

Wannabe

I have developed an application that opens a powerpoint template, inserts
data from our database into it, and displays it to the user. It works great
on my local development box. Problem is, when I run this from our server, I
only get a blank window, not the powerpoint application showing the chart. I
thought installing the Office 2K3 interoperability tools sdk on the server
would be enough. Is that not the case? Does my server need Office, or at
least powerpoint, installed?
 
M

Mark Rae [MVP]

Does my server need Office, or at least powerpoint, installed?

Under no circumstances install any part of Microsoft Office on your server
and attempt to instantiate it via remote automation. This is extremely risky
and is so unstable that Microsoft actively discourage it to the extent that
they will not support any application which attempts to do it:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

All you need is this:
http://www.aspose.com/Products/Aspose.Slides/Default.aspx
 
W

Wannabe

Thanks for the reply.

Our structure is such that it would take months to get approval to purchase
and install any third party software, such as Apose. I am only opening a
powerpoint template and then adding four text boxes to it. That's it. With
that little bit of work, you still say it is not a good thing. This is our
only option at the moment, and any other options would take months to
complete. This is on our intranet server, with no more than two or three
users at any one time, if that makes a difference.

Why would Microsoft offer the ability to hook into Powerpoint if they
recommend against it?

Here is the code that does this (and one section for inserting one textbox):

PowerPoint.Application pp = new
Microsoft.Office.Interop.PowerPoint.Application();
pp.Visible = MsoTriState.msoTrue;
PowerPoint.Presentations presentations = pp.Presentations;
PowerPoint._Presentation presentation =
presentations.Open("D:\\Templates\\quadchart.pot", MsoTriState.msoFalse,
MsoTriState.msoTrue, MsoTriState.msoTrue);
PowerPoint.Slides slides = presentation.Slides;
PowerPoint._Slide slide = slides.Add(1,
PowerPoint.PpSlideLayout.ppLayoutBlank);

//Title
Microsoft.Office.Interop.PowerPoint.Shape ppTitle =
slide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 100,
25, 600, 320);

ppTitle.TextFrame.TextRange.Text = projectName;
ppTitle.TextFrame.TextRange.Font.Size = 32;
ppTitle.TextFrame.TextRange.Font.Bold = MsoTriState.msoTrue;
 
M

Mark Rae [MVP]

This is our only option at the moment,

Can't help that... Aspose really isn't very expensive, and it will solve
your problem in about half an hour...
This is on our intranet server, with no more than two or three
users at any one time, if that makes a difference.

It doesn't... Read the MSDN article again...

Here's further information:
http://support.microsoft.com/default.aspx/kb/288367. Note specifically:
"risky and unstable", "stop responding", "corrupt data", "crash the calling
process", "bring down the web server" etc...

I'm really not making this up...
Why would Microsoft offer the ability to hook into Powerpoint if they
recommend against it?

Because it's simply not designed for remote automation on a server because
of its threading model - desktop automation works perfectly...
Here is the code that does this (and one section for inserting one
textbox):

<snip>

Makes no difference what your code is - it's just not designed to work in
this environment...

I suggest you show the two MSDN articles to your boss...
 
B

bruce barker

automation is supported from a client app, just not from a service (like
asp.net). the microsoft link gives reasons why. if you can live with the
cavets, then yes, you need to install powerpoint on the server. be sure to
follow all the links, and address each issue that applies.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top