PDA

View Full Version : Import pictures from a folder to an existing PowerPoint



clemleb
12-10-2020, 11:03 AM
Hello Everyone,

I am trying to create a clean presentation from an old one using the master slider (many texts were not recognized as a title or a text placeholder) as I need to change the whole design.

Thanks to a VBA code, I exported every text contents into a Word document which will be use as a database. (If everything is clean, I understand I can directly copy paste all texts from the outline view).

In this Word document, I put all the titles in level 1 and descriptions in level 2.

Then I created a blank presentation using slides from outlines and it works perfectly.

Now I have about 150 clean slides with no pictures.

I have already exported all the images by renaming my old presentation to *.zip and I have a media folder with every image named from 1.jpg/jpeg/png to XXX.jpg/jpeg/png

I would like to import them to the new presentation I have just created (which has titles and text placeholders) in the same order. I need them backward and fitting the whole slide.

Is there a way to do this using VBA? By the way, I would really love to understand better the VBA for PowerPoint but I see many courses for Excel. What is the "bible" for new learners?

Thank you very much for your help.

clemleb
02-10-2021, 12:34 PM
Hello everyone,

I come back with this code that does almost the same thing that I wanted
My only issue is that it inserts the pictures in new slides while I need the first picture to go the first slide, second to second, etc ...

Thank you very much


Sub PowerPoint_Import()
Dim ImgI AsLong, tmpDIAPO As Slide
With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Add "Images","*.gif; *.jpg; *.jpeg",1
If.Show =-1Then
For ImgI =1To.SelectedItems.Count
Set tmpDIAPO = ActivePresentation.Slides.Add(Index:=ImgI, Layout:=ppLayoutTitleOnly)
tmpDIAPO.Shapes.AddPicture FileName:=.SelectedItems.Item(ImgI),_
LinkToFile:=msoFalse,_
SaveWithDocument:=msoTrue,_
Left:=0, Top:=0,_
Width:=-1, Height:=-1
Next
EndIf
EndWith
EndSub

John Wilson
02-11-2021, 12:00 AM
Maybe

Sub PowerPoint_Import()
Dim ImgI AsLong, tmpDIAPO As Slide
With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Add "Images","*.gif; *.jpg; *.jpeg",1
If.Show =-1Then
For ImgI =1To.SelectedItems.Count
Set tmpDIAPO = ActivePresentation.Slides(ImgI)
tmpDIAPO.Shapes.AddPicture FileName:=.SelectedItems.Item(ImgI),_
LinkToFile:=msoFalse,_
SaveWithDocument:=msoTrue,_
Left:=0, Top:=0,_
Width:=-1, Height:=-1
Next
EndIf
EndWith EndSub