为什么我会得到使用PpShapeFormat在Office 2013互操作非法值误差 [英] Why am I getting an illegal value error using PpShapeFormat in Office 2013 Interop

查看:425
本文介绍了为什么我会得到使用PpShapeFormat在Office 2013互操作非法值误差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I wrote an MS JScript utility (for use in SmartBear's TestComplete) that exports images that are embedded in a Word document to PNG files on disk. When I run this utility on Win7, with Office 2010, everything works fine. But when I run it on Win8 with Office 2013, I get an "illegal value" error when passing the PpShapeFormat filter to the Export method.

下面是我的脚本中的相关部分:

Here's the relevant portion of my script:

//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,我发现这个<一个href=\"http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.ppshapeformat%28v=office.14%29.aspx\"相对=nofollow>枚举参考。但我无法找到2010年和2013年,以及如何正确地使用它没有很好的例子之间变化的任何文档。

Researching the PpShapeFormat, I found this Enumeration reference. But I'm having trouble finding any doc on changes between 2010 and 2013, and no good examples of how to use it properly.

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

Does anyone have any idea what's going on here?

推荐答案

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

So, as it turns out, Office 2013 documents (DOCX format) are really just compressed directories. This is true for both 2010 and 2013, in fact.

我真正需要摆在首位的事情,是从COM pressed目录提取图像。

All I really needed to do in the first place, was extract the images from the compressed directory.

这篇关于为什么我会得到使用PpShapeFormat在Office 2013互操作非法值误差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆