为什么我会得到使用PpShapeFormat在Office 2013互操作非法值误差(Why am

2019-10-18 10:31发布

我写了一个MS的JScript实用程序(在SmartBear的TestComplete使用),其出口嵌入一个Word文档中的PNG文件在磁盘映像。 当我运行Win7上此实用程序,使用Office 2010,一切工作正常。 但是,当我与Office 2013年的Win8运行它,我传递PpShapeFormat过滤器导出方法时得到一个“非法值”的错误。

这里是我的脚本的相关部分:

//get the list of shapes from the word doc, and how many there are
var iShapeList = DocObj.InlineShapes; //DocObj is created elsewhere
var iShapeTotal = iShapeList.count;

//create a powerpoint object and instantiate a presentation
var pptApp = Sys.OleObject("PowerPoint.Application"); //open PowerPoint
var pptDoc = pptApp.Presentations.Add(); //create a new blank document
var pptDocSlide = pptDoc.Slides.Add(1, 12); //12 = ppLayoutBlank
var pptShapeFmt = pptApp.PpShapeFormat; //format filter object

//loop through the Word document shapes, copy each one, paste it to the Ppt slide, 
//export the image out of the slide, and then delete it
for(var iShapeNo = 1; iShapeNo <= iShapeTotal; iShapeNo++)
{
   var iShape = iShapeList(iShapeNo); //get a shape
   iShape.ScaleHeight = hScale; //set the shape height and width
   iShape.ScaleWidth = wScale;

   iShape.Range.Copy();//copy the shape to the clipboard

   try 
   {
     with (pptDocSlide.Shapes.Paste(1)) //PpViewType 1 = Paste into Slide View
     {
        //Export the image pasted into the slide, to the extract path, then delete the slide.
         Export(ExtractPath + "\\" + IntToStr(iShapeNo) + ".png", pptShapeFmt); //2 = ppShapeFormatPNG            
         Delete();
         ++successTally; //one more in the WIN column!
     }
   }
   catch(exception)
   { 
      //does a bunch of cleanup
   }
}

研究的PpShapeFormat,我发现这个枚举参考。 但我无法找到2010年和2013年,以及如何正确地使用它没有很好的例子之间变化的任何文档。

有没有人有任何想法,这是怎么回事呢?

Answer 1:

所以,事实证明,办公文档2013(DOCX格式),实际上只是压缩目录。 这是2010年和2013真,其实。

我真正需要首先做的,就是从压缩目录提取图像。



文章来源: Why am I getting an illegal value error using PpShapeFormat in Office 2013 Interop