Powerpoint macro xử lý hình ảnh-object

 



1. Macro resize "selected shapes" then save it to assigned folder under name "pic1.png"


Sub SetSelectedImageResolution()

 Dim shp As shape

    Dim imgPath As String

    imgPath = Environ("USERPROFILE") & "\Desktop\pic1.png"    

    If ActiveWindow.Selection.Type = ppSelectionShapes Then

        Set shp = ActiveWindow.Selection.shapeRange(1)

        shp.LockAspectRatio = msoTrue

        shp.Width = 1280

        shp.Height = 1024

        shp.Export imgPath, ppShapeFormatPNG

       shp.Delete

    Else

        MsgBox "Select object before run macro.", vbExclamation

    End If

End Sub


 2 . Macro selects all shapes in current Slide, copy and paste under image format.


Sub CopyPasteAsPicture()

Dim slide As slide

Dim shape As shape

Dim shapeRange As shapeRange

' Get the current slide

Set slide = ActiveWindow.View.slide

' Select all shapes on the slide

slide.Shapes.SelectAll

' Copy selected shapes

Set shapeRange = Application.ActiveWindow.Selection.shapeRange

shapeRange.Copy

' Paste as picture

slide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile

End Sub


Nhận xét