Word 文書に埋め込まれた画像をディスク上の PNG ファイルにエクスポートする MS JScript ユーティリティ (SmartBear の TestComplete で使用するため) を作成しました。Office 2010 を使用して Win7 でこのユーティリティを実行すると、すべて正常に動作します。しかし、Office 2013 を使用して Win8 で実行すると、PpShapeFormat フィルターを Export メソッドに渡すときに「値が不正です」というエラーが発生します。
私のスクリプトの関連部分は次のとおりです。
//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 年までの変更に関するドキュメントを見つけるのに苦労しており、それを適切に使用する方法の良い例もありません。
ここで何が起こっているのか誰にも分かりませんか?