C# PIA PPT Automation URGENT!?

R

rhelsens

I am using the following simple code to copy certain slides from one
presentation to another using Office PIAs.

While this code works great for certain kits, one certains kits it
create huge files. Instead of ~2MB I am getting a 14 MB file. I have
been able to isolate the problem to only slide kits with alot of
text/graphs/etc...I assume this has to do with the embedded objects in
the source file, but why does the size increase? is there any
suggestion to handling this copy/paste for embedded objects versus just
text/shapes?


thanks in advance

foreach (DataRow dr in myDataTable.Rows) {
PowerPoint.Slide objSlide = objSource.Slides[ dr["slide_number"] ];
objSlide.Copy();
objDestination.Slides.Paste(objDestination.Slides.Count+1);
objDestination.Slides[objDestination.Slides.Count].Design =
objSlide.Design;
objDestination.Slides[objDestination.Slides.Count].ColorScheme =
objSlide.ColorScheme;
} //foreach
 
S

Steve Rindsberg

I am using the following simple code to copy certain slides from one
presentation to another using Office PIAs.

While this code works great for certain kits, one certains kits it
create huge files. Instead of ~2MB I am getting a 14 MB file. I have
been able to isolate the problem to only slide kits with alot of
text/graphs/etc...I assume this has to do with the embedded objects in
the source file, but why does the size increase? is there any
suggestion to handling this copy/paste for embedded objects versus just
text/shapes?

thanks in advance

foreach (DataRow dr in myDataTable.Rows) {
PowerPoint.Slide objSlide = objSource.Slides[ dr["slide_number"] ];
objSlide.Copy();
objDestination.Slides.Paste(objDestination.Slides.Count+1);
objDestination.Slides[objDestination.Slides.Count].Design =
objSlide.Design;
objDestination.Slides[objDestination.Slides.Count].ColorScheme =
objSlide.ColorScheme;
} //foreach

One thing to check: verify that you're adding a slide and not a PPT OLE object ON a
slide when you paste.

Also, make sure that the source files aren't unreasonably large. Turn off Fast
Saves, open and save a few of the problem ones and see if they shrink considerably.
 
R

rhelsens

Steve, thanks for the reply. done more testing and I'm seeing the
problem on the production server only, which is Windows Server 2003,
Office 2003 pro. but not the development machines

That is the strange part, for a source file of 4MB, we get a 14MB file,
it seems that most files come in around 14-15MB when created on the
server.

Considering the behavior occurs on one machine and not the other, does
this sound like an issue with Office? I have considered doing a repair
to Office to see what that gains.

thanks again for your thoughts
 
S

Steve Rindsberg

Steve, thanks for the reply. done more testing and I'm seeing the
problem on the production server only, which is Windows Server 2003,
Office 2003 pro. but not the development machines

That is the strange part, for a source file of 4MB, we get a 14MB file,
it seems that most files come in around 14-15MB when created on the
server.

Considering the behavior occurs on one machine and not the other, does
this sound like an issue with Office? I have considered doing a repair
to Office to see what that gains.

Again, do check that Fast Saves setting on the version of PPT installed on the
server. By default, it's on. You want it OFF.
 
R

rhelsens

Steve thanks, I am getting this error now, only on the production
server IIS6 windows 2003. Any tips on where to look, as to why this
works fine on dev box?

thanks

Slides (unknown member) : Invalid request. Clipboard is empty or
contains data which may not be pasted here.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Slides
(unknown member) : Invalid request. Clipboard is empty or contains data
which may not be pasted here.
 
S

Steve Rindsberg

Steve thanks, I am getting this error now, only on the production
server IIS6 windows 2003. Any tips on where to look, as to why this
works fine on dev box?

thanks

Slides (unknown member) : Invalid request. Clipboard is empty or
contains data which may not be pasted here.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Slides
(unknown member) : Invalid request. Clipboard is empty or contains data
which may not be pasted here.

Not a clue, I'm afraid. If you can work out the point at which this occurs,
try using a clipboard viewing utility on both boxes after pausing your code
just before the point at which the error occurs.

As an aside and FWIW, note that MS recommends against server side automation of
PowerPoint and the other Office apps.
 
R

rhelsens

steve, thanks for the help. I thought with the XP PIAs, this wasn't as
frowned upon.
thanks again
 

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

Similar Threads


Top