0

我想将图像粘贴到PowerPoint幻灯片中,然后在粘贴后调整其大小,

我不知道图像索引,所以它需要能够在粘贴后立即调整大小

以下不起作用,请有人帮忙

Sub PasteOnSlide()

Dim strPresPath As String
strPresPath = "c://myfile"
Set oPPTFile = oPPTApp.Presentations.Open(strPresPath)

oPPTFile.Slides(4).Shapes.PasteSpecial(ppPasteEnhancedMetafile).select

With Selection
    .Height = 270
    .Width = 680
    .Left = 20
    .Top = 120
    .ZOrder msoSendToBack
End With

End Sub

我也试过:

set MyShape = oPPTFile.Slides(4).Shapes.PasteSpecial(ppPasteEnhancedMetafile).select
With MyShape
    .Height = 270
    .Width = 680
    .Left = 20
    .Top = 120
    .ZOrder msoSendToBack
End With

End Sub
4

1 回答 1

0

哦,那么近...

避免使用Select, (并声明所有变量!)

Sub PasteOnSlide()
    Dim strPresPath As String
    Dim MyShape As Shape
    Dim oPPTFile As Presentation
    Dim oPPTApp As Application

    Set oPPTApp = Application
    strPresPath = "c://myfile"
    Set oPPTFile = oPPTApp.Presentations.Open(strPresPath)

    Set MyShape = oPPTFile.Slides(4).Shapes.PasteSpecial(ppPasteEnhancedMetafile).Item(1)

    With MyShape
        .Height = 270
        .Width = 680
        .Left = 20
        .Top = 120
        .ZOrder msoSendToBack
    End With
End Sub

您应该添加错误处理,包括覆盖剪贴板中没有任何内容可粘贴或strPresPath不指向现有演示文件的情况。

于 2013-10-10T05:01:44.777 回答