This is an old revision of the document!


Microsoft Office VBA

PowerPoint VBA

  • Change font to Headings or Body font:
    • {object}.Font.Name = "+" + FontType + "-" + FontLang
      • FontType is "mj" or "mn" for Major (headings) or Minor (body) respectively.
      • FontLang is "lt", "cs" or "ea" for Latin, Complex Scripts or East Asian
    • For example to set the font to the theme's body text font for Latin text: ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange.Font.Name = "+mn-lt"
  • PasteSpecial values:
Paste Type Enum VBA Code
Bitmap 1 ppPasteBitmap
Default 0 ppPasteDefault
Enhanced Metafile 2 ppPasteEnhancedMetafile
GIF 4 ppPasteGIF
HTML 8 ppPasteHTML
JPG 5 ppPasteJPG
Metafile Picture 3 ppPasteMetafilePicture
OLE Object 10 ppPasteOLEObject
PNG 6 ppPastePNG
RTF 9 ppPasteRTF
Shape 11 ppPasteShape
Text 7 ppPasteText
Sub EnhancedMetafile_Paste()
'PURPOSE:Paste Contents as PasteSpecial Enhanced Metafile
'SOURCE: www.TheSpreadsheetGuru.com
Dim Sld As Slide
'Ensure focus is on slide
    Application.ActiveWindow.Panes(2).Activate
    Set Sld = Application.ActiveWindow.View.Slide
    On Error GoTo NoCopy
        Sld.Shapes.PasteSpecial (ppPasteEnhancedMetafile)
    On Error GoTo 0
Exit Sub
NoCopy:
    MsgBox "There was nothing copied to paste!"
End Sub