Winform往2003版本的PPT中插入EMF格式图片抛出ArgumentException 未找到指定的文件。事实上已经存在了该文件了,往2007或者2010离插入就没有问题。捕捉到 System.ArgumentException
  Message=未找到指定文件。
  Source=""
  StackTrace:
       at Microsoft.Office.Interop.PowerPoint.Shapes.AddPicture(String FileName, MsoTriState LinkToFile, MsoTriState SaveWithDocument, Single Left, Single Top, Single Width, Single Height)
       at MacVan.PA.PPT.PPTCommon.AddPictruePage(String picFileName, String title, Int32 index, String re) in  PPTCommon.cs:line 514
  InnerException: 

解决方案 »

  1.   

        public void AddPictruePage(string picFileName, string title, int index, string re)
            {
                try
                {
                    objSlide = objSlides.Add(index, PowerPoint.PpSlideLayout.ppLayoutTitleOnly);
                    AddTitleToSlide(title, objSlide);                float picLeft = 100;
                    float picTop = 150;
                    float picHeight = 350;
                    float picWidth = 500;
                    float reLeft = 50;
                    float reTop = 100;
                    float reHeight = 100;
                    float reWidth = 600;
                    if (!string.IsNullOrEmpty(re))
                    {
                        PowerPoint.TextFrame objTextFrame = objSlide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, reLeft, reTop, reWidth, reHeight).TextFrame;
                        objTextRng = objTextFrame.TextRange;
                        objTextRng.Text = re;
                        objTextRng.Font.Size = 20;
                        picTop = reTop + objTextRng.BoundHeight;
                    }               
                    objSlide.Shapes.AddPicture(picFileName, MsoTriState.msoFalse, MsoTriState.msoTrue,
                       picLeft, picTop, picWidth, picHeight);
                }
                catch (ArgumentException err)
                {
                    
                }
            }