我写了一个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年,以及如何正确地使用它没有很好的例子之间变化的任何文档。
有没有人有任何想法,这是怎么回事呢?