Question

I have the following 'attempt at' a macro in PowerPoint which inserts a picture into the current slide:

Sub Insert_Traverse_2a()
    Dim oPic As Shape
    Set oPic = ActiveWindow.View.Slide.Shapes.AddPicture("\\nlamvfs00065\homes\nlkpec\newpic.png", False, True, 0, 0, -1, -1)
        oPic.ScaleHeight(100, msoTrue, msoScaleFromTopLeft)
End Sub

However, the line with "ScaleHeight" gives a syntax error. From the documentation on

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.shape.scaleheight(v=office.14).aspx

I don't see what I'm doing wrong?

(I would like PowerPoint to not resize the image, since this causes a loss of resolution. Without the 'ScaleHeight' line, however, PowerPoint automatically resizes the image if it's bigger than the slide).

Était-ce utile?

La solution

Remove the parentheses from the ScaleHeight method:

Sub Insert_Traverse_2a()
    Dim oPic As Shape
    Set oPic = ActiveWindow.View.Slide.Shapes.AddPicture("c:\users\david_zemens\desktop\logo.jpg", False, True, 0, 0, -1, -1)
        oPic.ScaleHeight 100, msoTrue, msoScaleFromTopLeft
End Sub

Also, make sure you're reviewing the correct version of the documentation. What you linked to is for VB.net, not VBA for PowerPoint:

http://msdn.microsoft.com/en-us/library/office/ff743874(v=office.14).aspx

Autres conseils

Just use the Call keyword

Call oPic.ScaleHeight(100, msoTrue, msoScaleFromTopLeft)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top