Ms office 为什么在Office 2013 Interop中使用PpShapeFormat时出现非法值错误

Ms office 为什么在Office 2013 Interop中使用PpShapeFormat时出现非法值错误,ms-office,automated-tests,office-interop,jscript,testcomplete,Ms Office,Automated Tests,Office Interop,Jscript,Testcomplete,我编写了一个MS JScript实用程序(用于SmartBear的TestComplete),它将嵌入Word文档中的图像导出到磁盘上的PNG文件。当我使用Office2010在Win7上运行此实用程序时,一切正常。但是,当我使用Office 2013在Win8上运行它时,将PpShapeFormat筛选器传递给导出方法时,会出现“非法值”错误 以下是我脚本的相关部分: //get the list of shapes from the word doc, and how many there

我编写了一个MS JScript实用程序(用于SmartBear的TestComplete),它将嵌入Word文档中的图像导出到磁盘上的PNG文件。当我使用Office2010在Win7上运行此实用程序时,一切正常。但是,当我使用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
   }
}
//从word文档中获取形状列表,以及有多少个形状
var iShapeList=DocObj.InlineShapes//DocObj是在别处创建的
var iShapeTotal=iShapeList.count;
//创建powerpoint对象并实例化演示文稿
var pptApp=Sys.OleObject(“PowerPoint.Application”)//打开PowerPoint
var pptDoc=pptApp.Presentations.Add()//创建新的空白文档
var pptDocSlide=pptDoc.Slides.Add(1,12)//12=ppLayoutBlank
var pptShapeFmt=pptApp.PpShapeFormat//格式筛选器对象
//循环浏览Word文档形状,复制每个形状,将其粘贴到Ppt幻灯片,
//将图像从幻灯片中导出,然后将其删除

对于(var-iShapeNo=1;iShapeNo所以,事实证明,Office 2013文档(DOCX格式)实际上只是压缩目录。事实上,2010年和2013年都是如此


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

因此,事实证明,Office 2013文档(DOCX格式)实际上只是压缩目录。事实上,2010年和2013年都是如此


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

您是否也可以发布
导出
函数代码?@Helen-导出方法是在Powerpoint形状对象上实现的,它是Microsoft Office Interop库的一部分。您可以在此处找到该方法的文档:现在考虑到这一点,我想知道在2013年,他们是否已经开始要求剩下的参数了。(ScaleWidth、ScaleHeight和ExportMode,我认为所有这些参数都是可选的,因为该方法在2010年运行良好)。是的,这并没有解决问题。如果有什么问题的话,那会使情况变得更糟(扩展被搞砸了)。因此,它回到了绘图板上。看起来PowerPoint 2013中的
形状
对象没有使用
导出
方法:您是否也可以发布
导出
功能代码?@Helen-导出方法在PowerPoint形状对象上实现,该对象是Microsoft Office Interop库的一部分。您可以找到该文档这里对方法的解释:现在我想起来了,我想知道他们是否在2013年开始需要剩下的参数。(ScaleWidth、ScaleHeight和ExportMode,我认为所有这些都是可选的,因为该方法在2010年工作得很好)。是的,这并没有解决问题。如果有什么问题的话,那会使问题变得更糟(扩展混乱)。因此,它回到了绘图板上。看起来PowerPoint 2013中的
形状
对象没有使用
导出
方法: