Skip to content

Instantly share code, notes, and snippets.

@marceloszilagyi
Created November 1, 2017 22:00
Show Gist options
  • Save marceloszilagyi/d4f77a551549140b8062126c5a7eddff to your computer and use it in GitHub Desktop.
Save marceloszilagyi/d4f77a551549140b8062126c5a7eddff to your computer and use it in GitHub Desktop.
Add image from folder
Sub Insert_Pics()
Dim strTemp As String
Dim strPath As String
Dim strFileSpec As String
Dim oSld As Slide
Dim oPic As Shape
' logos will be inserted in the alpha sequence; I renamed files with leading numbers (001, 002)
strPath = "C:\Users\logos\"
strFileSpec = "*.*"
strTemp = Dir(strPath & strFileSpec)
ActiveWindow.View.GotoSlide (1)
Do While strTemp <> ""
Set oSld = ActivePresentation.Slides(1 + j)
Set oPic = oSld.Shapes.AddPicture(FileName:=strPath & strTemp, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=520, _
Top:=82, _
Width:=-1, _
Height:=-1)
oPic.LockAspectRatio = msoTrue
oPic.Height = 25
strTemp = Dir
j = j + 1
Loop
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment