Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inserting Image to the Powerpoint slide using C# from remote jpg f

455 views
Skip to first unread message

Hriday

unread,
Apr 16, 2010, 1:28:06 PM4/16/10
to
Hi,
I am using Microsoft.Office.Interop.PowerPoint (office 2007) to create a PPT
slide from my C# code. I want to display an image on my slide from a jpg file
which is located at different file server. When I use following line to add
image by giving the file path strPicPath, it displays the image if strPicPath
is a path of a .jpg file of my application server. But it generates error
when I change strPicPath to a remote file server path. Because file server
path is not accessible from my application server for security reason. But
client machine does have access to the file server path. I tried linking the
image file using MsoTriState.msoTrue, but seems it still needs the .jpg file
to create the image.

objSlide.Master.Shapes.AddPicture(strPicPath, MsoTriState.msoTrue,
MsoTriState.msoFalse, 398, 43, 309, 200);

My requirement is to display the image on the Slide from a given .jpg file.
And I am able to do this by using the Shapes.AddPicture and providing the
path of .jpg file.

The problem comes when .jpg file is not accessible, this means when I use
the path of a local jpg file it works fine, and when I use the remote path
for jpg file (a different file server) then it does not work because my C#
code can not access the jpg file located at file server (because application
server does not have access permission to jpg file on file server). But the
actual end users of application do have the access to the jpg image file.

That is why I am looking if there is a way to just give the path of jpg file
in my server side coding and it can be rendered (displayed) on the PPT at
client side. I can not create the image at server side as my Application
server can not access the jpg file.

Is there any way to just create a blank image in PPT with a link to a .jpg
file so that when that PPT is opened at client machine, image is displayed
using the .jpg file from the file server? My scenario is something like using
href in html with a remote image path, but I do not know how to do this in
PPT using C#.

Thank you very much for any help.

--
HridayNarayan Rai
MCAD.

Steve Rindsberg

unread,
Apr 17, 2010, 11:57:33 AM4/17/10
to

Obviously PowerPoint won't allow you to insert an image that it doesn't have
access to.

But it also won't let you create a link to an image that's not where the link
points, so your code wouldn't be able to link to the image unless you have acces
to the image.

One possible workaround: map a drive letter to a folder you DO have access to,
put a "dummy" image there and link to it. The link now points to e.g.
"X:\photos\your_image.jpg". Create the same drive map at the user end and make
sure the image is there as well. The link should then work.

That assumes that you have some degree of control over the machines at the other
end, of course.

==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/


0 new messages