1

hopefully you guys can help me here. I have this excel interop picture code that seems to be only working on my end. The picture is in a folder in the mapped network drive. When I run the code and receive the excel file, the picture is on the file.

Microsoft.Office.Interop.Excel.Range picRange = xlWorkSheet.get_Range("A1:G1");
picRange.Merge(Type.Missing);
Microsoft.Office.Interop.Excel.Pictures p = xlWorkSheet.Pictures(misValue) as Microsoft.Office.Interop.Excel.Pictures;
Microsoft.Office.Interop.Excel.Picture pic = null;
pic = p.Insert(Server.MapPath("~/images/letter.gif"), misValue);
pic.Left = 87;
pic.Top = Convert.ToDouble(picRange.Top);
pic.Height = 80.25;
pic.Width = 320;
pic.Placement = Microsoft.Office.Interop.Excel.XlPlacement.xlFreeFloating;

However, if I run the code on a different computer, which also has access to that mapped network drive, it the excel file comes with an error on the image that says:

the linked image cannot be displayed. The file may have been moved renamed or deleted

I've checked three times and made sure that the image file is the right name and the right place. But it only seems to work locally on my computer.

Is there a function in the excel interop library where I can create an instance of the image instead of linking to the image file? Any help will do.

David Lee
  • 143
  • 1
  • 12
  • This may be security related. I have had issues in the past with remote image files in other MS Office products when the file was located on a network drive. – pstrjds Dec 16 '15 at 16:42
  • Not sure if its security related. I'll check it out right now and let you know if it works. If not, is there any function within the excel interop library that can create an instance of the image and embed the image instead of just linking to the image? – David Lee Dec 16 '15 at 16:46
  • Here is a link to a similar question on how to load the image into Excel vs linking. http://stackoverflow.com/questions/11716873/how-to-insert-a-picture-in-to-excel-from-c-sharp-app – Bearcat9425 Dec 16 '15 at 16:51
  • First thing I would do is either modify this program, or write a new program to see if both situations verify that the the file Server.MapPath("~/images/letter.gif") exists. If the file is not visible due to permissions, that should help you resolve the issue. – Owen Ivory Dec 16 '15 at 18:00
  • That sounds like a good idea Owen. I'll do that and let you guys know how it turns out. – David Lee Dec 16 '15 at 19:19

0 Answers0