在Powerpoint中使用vbscript如何调整嵌入式OLE xls对象中的显示范围?

时间:2014-06-14 10:43:39

标签: excel vbscript powerpoint

我的问题是我将xls-sheets合并到了一个powerpoint-presentation中。有时最后3列在对象中不可见。如果您双击对象并在Excel中查看它们,它们就在那里。 我想在vbscript中设置嵌入对象图标应显示的范围。 (可以通过双击对象手动完成,并在双击后拖动位于对象每侧中间的小黑方块。)

我已经尝试了2天来解决这个小问题。我已经尝试了OLEFormat和这个http://msofficeautomation.wordpress.com/2012/06/11/add-excel-sheet-via-addoleobject-into-powerpoint/没有任何运气。 我试图在Word中录制一个宏,因为我没有ppt中的记录功能,但是当录制宏时,你无法重新定义对象中显示的范围。 : - (

我在powerpoint本身附加了一个小例子,添加了一个名为C:\ temp \ addOLEObject_problem \ Book1.xlsx的xlsx文件

Sub AddObject()

 Set PPSlide = ActivePresentation.Slides.Add(ActivePresentation.Slides.Count + 1, 16)
 Set objShapeOLE = PPSlide.Shapes.AddOLEObject(0, 0, , , ,"C:\temp\addOLEObject_problem\Book1.xlsx", False)
 ' Set objShapeOLE = PPSlide.Shapes.AddOLEObject(0, 0, , , , ".\Book1.xlsx", False)
 ' Resize to fill the slide
 '  ******check if width or height of the picture is larger than the slide*******
 defaultWidth = objShapeOLE.Width
 defaultHeight = objShapeOLE.Height
 wRatio = PPSlide.Master.Width / objShapeOLE.Width 'Will be smaller and smaller the more resizing that is needed of the larger picture
 hRatio = PPSlide.Master.Height / objShapeOLE.Height ' if >1 no resize is needed

 resizeRatio = 1
 If wRatio < hRatio Then
     resizeRatio = wRatio
 Else
     resizeRatio = hRatio
 End If
 objShapeOLE.Width = resizeRatio * objShapeOLE.Width

 '????How to set the range being displayed in the object?????

End Sub

Brgds 安迪

0 个答案:

没有答案
相关问题