0
非法值的错误,我写了一个MS的JScript实用程序(在SmartBear的TestComplete使用),其出口嵌入一个Word文档中的PNG文件在磁盘映像。当我在Win7上运行此实用程序时,使用Office 2010时,一切正常。但是,当我使用Office 2013在Win8上运行它时,将PpShapeFormat过滤器传递给Export方法时,出现“非法值”错误。为什么会出现在Office 2013使用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,我发现这个Enumeration参考。但是我无法在2010年到2013年期间找到有关更改的文档,也没有关于如何正确使用它的好例子。
有没有人有任何想法这里发生了什么?
你能否也请发布'出口'功能代码? – Helen
@Helen - Export方法在Powerpoint Shape对象上实现,该对象是Microsoft Office Interop库的一部分。你可以从这里找到方法的文档:http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shape.export(v=office.14).aspx –
现在想想关于它,我想知道是否在2013年,他们已经开始要求剩下的论点。 (ScaleWidth,ScaleHeight和ExportMode,我假设所有这些都是可选的,因为该方法在2010年可以正常工作)。 –