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
}
}
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?