How Power Point slides picture can be tranfer to word document pic
Hi,
I am facing problem while transfering pictures from Powerpoint slides to word
document, as i was successfull in transferring text data from powerpoint
slide to word document, Can anyone help me to resolve my problem. As i dont
want to save temporarily the images on hard disk, but direclty transfer it to
word document.
the code is shown below:
I have taken refences
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Word = Microsoft.Office.Interop.Word;
and some code
public class PptToWord
{
PowerPoint.Application objApp;
PowerPoint.Presentations objPresSet;
PowerPoint._Presentation objPres;
PowerPoint.Slides objSlides;
public void CreateFile(StringCollection array)
{
String strTemplate;
strTemplate = "C:\\TFSPRESENTATION.ppt";
try
{
//Create a new presentation based on a template.
objApp = new PowerPoint.Application();
objPresSet = objApp.Presentations;
objApp.Visible = MsoTriState.msoTrue;
objPres = objPresSet.Open(strTemplate,MsoTriState.msoFalse ,
MsoTriState.msoTrue, MsoTriState.msoTrue);
objSlides = objPres.Slides;
// word doc
object oMissing = System.Reflection.Missing.Value;
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,ref
oMissing, ref oMissing);
//oWord.ActiveDocument.InlineShapes.AddPicture();
foreach(PowerPoint._Slide slide in objSlides)
{
foreach(PowerPoint.Shape Slideshape in slide.Shapes)
{
if (Microsoft.Office.Core.MsoTriState.msoTrue ==
Slideshape.HasTextFrame)
{
if (Microsoft.Office.Core.MsoTriState.msoTrue ==
Slideshape.TextFrame.HasText)
{
//MessageBox.Show(Slideshape.TextFrame.TextRange.Text);
Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref
oMissing);
oPara1.Range.Text =
Slideshape.TextFrame.TextRange.Text;
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24; //24 pt
spacing after paragraph.
oPara1.Range.InsertParagraphAfter();
}
}
if(Microsoft.Office.Core.MsoShapeType.msoPicture==Slideshape.Type)//for image
{
//Word.Shape oPicture;
// oPicture = (Word.Shape)Slideshape
// I am facing problem here, as i m not able to directly transfer pictures
from power point slides to word document pictures.
// I dont want to save images on temprory location to my system hard disk.
Can anyone guide me to do the same.
}
}
}
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
}
Thanks and Regards
Haroon(SolnTryst)
date: Thu, 26 Jun 2008 00:36:00 -0700
author: SolnTryst (Haroon)