Hi Experts.
Iam trying to add embedded object to powerpoint slide ..
yes i can add the object to powerpoint slide(helping from aspose),but my question is after running the particular ppt file the embedded object is not opening(if i click/double click on the object) ..
so please help me how to open that object while slide show using c#??
Thanks in advance.
Mohan raju
Hi Mohan,
Thanks for your interest in Aspose.Slides.
Please visit
this documentation link to see how to add Ole frames inside PPT. If you still feel any issue then please share the sample code that you are using along with word or excel file that you are trying to add as ole frame. Please also share the generated output for reference.
Many Thanks,
HI Mudassir,
Thanks for u r reply..
This is the code iam using nw..
string file = Server.MapPath("~/images/Presen#tation1.pptx");
//FileStream fis = new FileStream("template.pptx", FileMode.Open, FileAccess.Read);
PresentationEx pres = new PresentationEx(file);
SlideSizeEx sldSize = pres.SlideSize;
SlideEx sld = pres.Slides[1];
Stream pic = new FileStream(@"C:\Users\mohan.b\Desktop\excell.jpg", FileMode.Open);
Bitmap rim = new Bitmap(pic, false);
ImageEx image = pres.Images.AddImage(rim);
FileStream fs = new FileStream("d:\\test.xlsx", FileMode.Open, FileAccess.Read);
// FileStream fs = new FileStream("~/images/IDCardPDFs.pdf", FileMode.Open, FileAccess.Read);
//MemoryStream mstream = new MemoryStream();
byte[] buf = new byte[fs.Length];
fs.Read(buf, 0, (int)fs.Length);
//while (true)
//{
// int bytesRead = fs.Read(buf, 0, buf.Length);
// if (bytesRead <= 0)
// break;
// mstream.Write(buf, 0, bytesRead);
//}
OleObjectFrameEx oof = sld.Shapes.AddOleObjectFrame(0, 0, sldSize.Size.Width, sldSize.Size.Height, "Excel.Sheet.12", buf);
oof.Image = image;
pres.Write("d:\\template_.pptx");
This is working fine and inserting the object into the pptx file but when i open pptx file (slide show) the inserted object is not opening ??? please help me where should i change the code???
Please check the ouput at slideshow of the "template_.pptx".
Thanks in advance.
Hi Mohan,
The code snippet shared by you looks fine. Please share the source presentation along with files to embed as OIe frames and generated output. I will try reproducing the issue on my end to help you out further.
Many Thanks,
Dear Mudassir Fayyaz ,
I have attached the .pptx file ,please find the attachment.
In this .pptx file go to the second slide where i have added the embedded object (Excel file) using c#.net code which is already i have sent.
Requirement: while slide show this pptx ,if i double click on the excel object it has to navigate to excel prompt and has to open file in excel environment.
i hope u can understand clearly.
Thanks in advance.
Regards,
Mohan Raju
Hi
Mohan Raju,
I have tried to understand the requirements shared by you and you have stated that you need to re-direct to excel prompt when you double click on Ole frame in Slide Show. I regret to share that even in PowerPoint it self if you add an Ole object, it will not re-direct to excel file. Actually, in Slide Show mode the mouse clicks or other events are used in slide transitions or other effects. One option that you can do is to set hyperlink to target excel file displayed in the Ole frame. When in slide show you will click on the ole frame, it will open the desired file in MS Excel. That is the only option that can be used for instance. You can use both PowerPoint and Aspose.Slides for setting hyperlink to Ole frame shape. For your kind reference, I have shared the presentation that I have created in PowerPoint. On slide 2, I have hyperlinked Ole frame. So, when in Slide Show mode, you will click on Ole frame, it will launch the instance of MS Excel. I hope this will fulfill the requirements on your end.
Many Thanks,
Dear Mudassir Fayyaz ,
Thanks for u r valuble reply.. could u please share that hyperlink code along with my code ????
Using aspose.slides
Thanks in advance....
Mohan Raju
Hi Mohan Raju,
Please use the following code snippet for your further investigation. Please share if I may help you further in this regard.
Presentation pres = new Presentation();
//Reading excel chart from the excel file and save as an array of bytes
FileStream fstro = new FileStream(path + “test.xls”, FileMode.Open, FileAccess.Read);
byte[] b = new byte[fstro.Length];
fstro.Read(b, 0, (int)fstro.Length);
//Inserting the excel chart as new OleObjectFrame to a slide
OleObjectFrame oof = pres.Slides[0].Shapes.AddOleObjectFrame(500, 500,2500,2500, “Excel.Sheet.8”, b);
oof.AddLink().SetExternalHyperlink(path + “test.xls”);
pres.Write(path + “TestOle.ppt”);
Many Thanks,
Dear Mudassir Fayyaz ,
Its great job..its working fine..thanks a lot.
But this is working in OleObjectFrame class but iam using OleObjectFrameEx
where i could not find link methods ..
could u please share the code how to implement in the OleObjectFrameEx classs
Thanks in advance...
Hi Mohan Raju,
Please use the following code snippet for OleObjectFrameEx implementation. Please share, if I may help you further in this regard.
String path = @“C:\Users\Mudassir\Downloads”;
PresentationEx pres = new PresentationEx();
//Reading excel chart from the excel file and save as an array of bytes
FileStream fstro = new FileStream(path + “test.xls”, FileMode.Open, FileAccess.Read);
byte[] b = new byte[fstro.Length];
fstro.Read(b, 0, (int)fstro.Length);
//Inserting the excel chart as new OleObjectFrame to a slide
OleObjectFrameEx oof = pres.Slides[0].Shapes.AddOleObjectFrame(60, 60, 400, 400, “Excel.Sheet.8”, b);
HyperlinkEx link=new HyperlinkEx(path + “test.xls”);
pres.Write(path + “TestOle.pptx”);
Many Thanks,
Dear Mudassir Fayyaz,
Thank u soooooooo much its working great, great job.
Thanks.
Mohan raju