PDA

View Full Version : How to? Insert image as background on slide - 20 slides, 20 images then repeat



jamee
08-27-2020, 11:54 AM
Hi. Telling you straight up. I'm a beginner. So thanks in advance for all knowledge you pass on.

Situation:
I have a 20 slide deck. I have to manually insert an image as the background on each slide... So... Background Styles, Format background, insert picture or texture fill radio button, 'Insert' button as picture choice, select image in finder window, then Insert.

Repeat for each slide because each slide gets a different background.

1st Ask: is it possible to automate this? All the images are in the same folder, image-1.png, image-2.png etc.

2nd Ask: if it is possible, what's the fastest/best way to repeat the process is the image.png files have been updated.

Any help is greatly appreciated!

Thanks!

John Wilson
08-28-2020, 08:09 AM
It is definitely possible. You might want to add the full path to the folder with images and confirm that the images are named Image-1.png ....Image-20.png.

It will help if you say that you know (or don't) how to access the vb editor, insert a module and copy in code.

jamee
08-28-2020, 12:04 PM
Thanks John, good to know it's possible.

So I'm a super beginner. I have no idea where to start with writing the code.

Could someone get me started?

John Wilson
08-29-2020, 04:36 AM
Can you answer the two questions about folder path and image names?

jamee
08-31-2020, 07:52 AM
Hi John,
My apologies. You were so kind in the phrasing of your initial response, that I didn't realize it was a question :)


The images will always follow this nomenclature: Background_slide_1.png, Background_slide_2.png, etc.


The images will always be in a folder named 'Indesign_PNGs_for_ppt'


Here is the full path if relavant. ~/Documents/Project-name/PowerPoint/Indesign_PNGs_for_ppt


Thank you!
J

John Wilson
08-31-2020, 08:07 AM
The code would look like this


Sub BackG()
Dim L As Long
Dim strFolder As String
'note this will need to be ammended to point to your docs folder
strFolder = "C:\users\your name\Documents\Project-name/PowerPoint/Indesign_PNGs_for_ppt\"
For L = 1 To 20
ActivePresentation.Slides(L).FollowMasterBackground = False
With ActivePresentation.Slides(L).Background.Fill
.UserPicture (strFolder & "Background_slide__" & CStr(L) & ".png")
.Visible = True
End With
Next L
End Sub

NOTE ~/Documents/Project-name/PowerPoint/Indesign_PNGs_for_ppt IS NOT the full path to the folder and you will need to change the path in the code too.

jamee
08-31-2020, 09:23 AM
Hi John,
Thank you so much! I must be doing something wrong. I get a run-time error. Here are snaps of the error, the debug, and my folder structure.
I should make note: I'm on a mac running PowerPoint for Mac Version 16.40. I'm wondering if I just can't find the right syntax for the absolute path to the folder.
27032
27031
27030

Thank you so much for helping!

John Wilson
08-31-2020, 09:41 AM
I'm not realloy a lot of help on Macs.

Try deleting C: from the folder path.