Inserting PictureFrame in PPTX with external image link works- but not in PPT

I’m adding a picture frame to the masterslide in powerpoint and setting the link (picture url) to and external site. Works in PPTX format, but can’t figure out how to do this in PPT format.

In PowerPoint, the steps are View/SlideMaster, Insert Picture, paste URL in File Name text box, and under Insert choose “Insert and Link”.

Code for pptx below, and trying to do the same for ppt.

Aspose.Slides.Pptx.MasterSlideEx slide = presentation.Masters[0];

string picLoc = @"http://mysite.com/myimage.gif";

int pfID = slide.Shapes.AddPictureFrame(Aspose.Slides.Pptx.ShapeTypeEx.Rectangle,1,1,1,1,null);

Aspose.Slides.Pptx.PictureFrameEx pfx =
slide.Shapes[pfID] as Aspose.Slides.Pptx.PictureFrameEx;

pfx.PictureFormat.Picture.Url
= picLoc;

PPT code below. I am getting a new 40x40 pictureframe, but not linked to external picture.

Slide slide = presentation.MainMaster;

string picLoc = @“http://mysite.com/myimage.gif”;

Picture pic = new Picture(presentation, new Bitmap(40, 40));

int picID = presentation.Pictures.Add(pic);

PictureFrame pf = slide.Shapes.AddPictureFrame(picID,1,1,40,40);

pf.PictureFileName = picLoc;

Hi Dale,

Thanks for your interest in Aspose.Slides.

I have observed the requirement shared by you and request you to please share the more details with us regarding them. As far as your code is concerned, it seems fine. Please share the requirement in terms of desired presentation and actual output you are getting. I will try my best to help you further in this regard.

Many Thanks,

Hi Dale,

As I understand your requirement, you need to add an external link to your picture frame in PPT file (as you have done for PPTX file). To achieve this, you can use PictureFrame.AddLink method and then set the link to external site. You may check the following code segment which adds an external link to picture frame in a PPT file.

//Instantiate a Presentation object that represents a PPT file
Presentation presentation = new Presentation("d:\\input.ppt");

//Accessing master slide
Slide slide = presentation.MainMaster;

string picLoc = @"http://mysite.com/myimage.gif";

//instantiate a Picture object
Picture pic = new Picture(presentation, new Bitmap(40, 40));
int picID = presentation.Pictures.Add(pic);

//Adding picture frame to the slide
PictureFrame pf = slide.Shapes.AddPictureFrame(picID, 1, 1, 40, 40);

//Set file name of picture
pf.PictureFileName = picLoc;

//Add Link to picture frame
Link link = pf.AddLink();

//Set external link to picture frame
link.SetExternalHyperlink(picLoc);

//save updated presentation
presentation.Write("d:\\data\\modified.ppt");

Hopefully the above code will fulfill your requirement.

Thanks & Regards,
Owais Ahmad

I found a workaround for PPT files (link below). I don’t want an external hyperlink. What I want is the picture to be linked to an external url which it goes out and gets each time the PPT is opened. Using the workaround below, PPT files worked just fine and each open caused the master to reach out to the url for the picture and pull the latest image.

What I need to automate is:

Insert a picture in master slide. Insert Picture in PPT, paste in URL to filename and the button that says Link is where you click the drop down and choose “Link and Insert”. I can attach screenshots if you need them.

https://forum.aspose.com/t/97735

I need to Insert and Link an image to external URL as noted in the post below. The image must be rendered from the remote server everytime the PPT is opened (could be a new image on the remote server).

https://forum.aspose.com/t/33730

We use the Shapes.AddLinkedPicture function in Aspose.Cells to add a picture as a URL link into a XLS file. What is the equivalent function in Aspose.Words and Aspose.Slides to achieve the same thing in DOC and PPT files?



Hi Dale,

I checked the scenario for both PPT and PPTX files with the below sample code and Aspose.Slides for .NET v8.0 and it works fine. Images are properly updating on opening PPT and PPTX files if the source image is changed.

For PPT Files:

//Instantiate a Presentation object that represents a PPT file
Presentation presentation = new Presentation("d:\\data\\input.ppt");

//Accessing a slide using its slide position
Slide slide = presentation.MainMaster;

string picLoc = @"http://localhost:58153/files/1.jpg";
Picture pic = new Picture(presentation, new Bitmap(40, 40));
int picID = presentation.Pictures.Add(pic);

//Adding picture frame to the slide
PictureFrame pf = slide.Shapes.AddPictureFrame(picID, 1, 1, 40, 40);
pf.PictureFileName = picLoc;

//Writing the presentation as a PPT file
presentation.Write("d:\\data\\modified.ppt");

For PPTX Files:

//Instantiate PresentationEx class that represents the PPTX
PresentationEx pres = new PresentationEx("d:\\data\\input.pptx");

//Get the first slide
MasterSlideEx slide = pres.Masters[0];

string picLoc = @"http://localhost:58153/files/1.jpg";

int pfID = slide.Shapes.AddPictureFrame(Aspose.Slides.Pptx.ShapeTypeEx.Rectangle, 1, 1, 40, 40, null);
Aspose.Slides.Pptx.PictureFrameEx pfx = slide.Shapes[pfID] as Aspose.Slides.Pptx.PictureFrameEx;
pfx.PictureFormat.Picture.Url = picLoc;

//Write the PPTX file to disk
pres.Write("d:\\data\\output.pptx");

You can try the above sample code and see if it works fine for you. Also, I am using .NET Framework 2.0 with Aspose.Slides for .NET v8.0 and getting the desired results.

Thanks & Regards,

I was wrong on the PPTX code I was using. It does work and updates the image each time - if server where remote image is located is responding slowly it appears that it isn't working.

I'll try the code for PPT instead of the work-around that was posted. Will check version of Aspose libraries and .net framework being used.

I changed the Target Framework for the project to .NET 2.0, downloaded Aspose.Slides for .NET 8.0.0 and installed the DLLs to a different folder. I removed the reference to Aspose.Slides (version 7.6) and added a reference to Aspose.Slides (properties show Runtime version v2.0.50727 and Version 8.0.0.0).

For PPT files, the code I used is the same as what you said should work, but it doesn't insert the image. The master slide has a picture frame, but no image (used google logo url). Also used url to internal server with image and same results with picture frame in Master but no image.

To test PPT files I'm using PowerPoint 2007 and saving to PPT format.

Slide slide = presentation.MainMaster;

Picture pic = new Picture(presentation, new Bitmap(40, 40));

int picID = presentation.Pictures.Add(pic);

PictureFrame pf = slide.Shapes.AddPictureFrame(picID, 1, 1, 40, 40);

pf.PictureFileName = @"https://www.google.com/images/srpr/logo11w.png";

Presentation.Write(outputfolderPath + document.newFileName);

This doesn't seem to work for PPT files even using v8.0 and 2.0 framework dll. I switched back to Aspose.Slides 7.6.0.0 and the dll for v4.0.30319. My project target framework is .NET Framework 4.

Any other ideas?

Hi Dale,

I have observed the solution shared by Owais and have observed them right. I have verified the requirement on my end and it seems to be an issue with Aspose.Slides while setting linked picture frame. I have created an issue with ID SLIDESNET-34802 in our issue tracking system to further investigate and resolve the issue while setting linked picture frame in case of PPT. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,

The issues you have found earlier (filed as SLIDESNET-34802) have been fixed in this update.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan