help w/ VB code for multiple pics

C

crtas1

I need help with this VB code. I am a total beginner and am not sure
where or what I am supposed to do to make this code to work in Power
Point. Can someone please walk me though this. Maybe highlight in red
what I am supposed to change in the code and what should be there.
Thanks

Sub ImportABunch()

Dim strTemp As String
Dim strFileSpec As String
Dim oSld As Slide
Dim oPic As Shape

strFileSpec = "C:\PFS Pictures\beach party *.PNG"
' Ex. on a PC: "C:\My Pictures\Flowers\*.PNG"

strTemp = Dir(strFileSpec)

Do While strTemp <> ""
Set oSld = ActivePresentation.Slides.Add ppLayoutBlank
Set oPic =
ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:=strFileSpec,
_
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=0, _
Top:=0, _
Width:=100, _
Height:=100)

' Reset it to its "real" size
With oPic
ScaleHeight 1, msoTrue
ScaleWidth 1, msoTrue
End With

' and optionally, make it fill the slide - to do that, uncomment the
following:
' With oPic
' .Height = ActivePresentation.PageSetup.SlideHeight
' .Width = ActivePresentation.PageSetup. SlideWidth
' End n

' Get the next file that meets the spec and go round again
strTemp = Dir
Loop

End Sub
 
S

Steve Rindsberg

A few clicks north of where you found that code, you'll also find this:

How do I USE this VBA stuff in PowerPoint?
http://www.rdpslides.com/pptfaq/FAQ00033.htm

You've posted the code you're having trouble with ... Ten Point Bonus.
But you didn't tell us what you expect it to do and what it's not doing.
Minus five points.
<g>

At a guess, it's not importing anything because this:

strFileSpec = "C:\PFS Pictures\beach party *.PNG"

should be this instead:

strFileSpec = "C:\PFS Pictures\beach party\*.PNG"

That is, it should be that if you're looking to import all the PNG files in
teh C:\PFS Pictures\Beath Party folder

--
Posted to news://msnews.microsoft.com
Steve Rindsberg, PPT MVP
PowerPoint FAQ - www.pptfaq.com
PPTools - www.pptools.com
===============================
 
C

crtas1

I am looking for this code to take a folder full of about 200 picture
and insert new slides and then insert all of the pictures on their ow
slide. I have inserted the new file location as you suggested but I a
erroring out with a compile error syntax error on the following lin
(2nd line)Set oSld = ActivePresentation.Slides.Add ppLayoutBlank

Do While strTemp <> ""
Set oSld = ActivePresentation.Slides.Add ppLayoutBlank
Set oPic
ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:=strFileSpec
_
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=0, _
Top:=0, _
Width:=100, _
Height:=100)

I am probably supposed to change this line to something but I have n
clue as to wha
 
S

Steve Rindsberg

(2nd line)Set oSld = ActivePresentation.Slides.Add ppLayoutBlank

My bad ... sorry. That should have been:

Set oSld = ActivePresentation.Slides.Add(ActivePresentation.Slides.Count +
1, ppLayoutBlank)
 
J

John Langhans [MSFT]

[CRITICAL UPDATE - Anyone using Office 2003 should install the critical
update as soon as possible. From PowerPoint, choose "Help -> Check for
Updates".]

Hello,

Did you know that you could batch import into PowerPoint 2000 and later
without having to write your own solution?

PowerPoint 2000, 2002 and 2003 have a Photo Album feature that does exactly
this. For PowerPoint 2000 it's a free Microsoft add-in that needs to be
downloaded, but for PowerPoint 2002/2003 the feature is built in and
available from "Insert -> Pictures -> New Photo Album"

The PowerPoint 2000 add-in can be downloaded from:

http://www.microsoft.com/downloads/details.aspx?FamilyID=55D24B47-C828-4141-
A8DE-9A459C63DB1A&displaylang=en

If you (or anyone else reading this message) think that PowerPoint should
include additional features and options for bulk inserting of images
(without having to resort to VBA or add-ins), don't forget to send your
feedback (in YOUR OWN WORDS, please) to Microsoft at:

http://register.microsoft.com/mswish/suggestion.asp

As with all product suggestions, it's important that you not just state
your wish but also WHY it is important to you that your product suggestion
be implemented by Microsoft. Microsoft receives thousands of product
suggestions every day and we read each one but, in any given product
development cycle, there are only sufficient resources to address the ones
that are most important to our customers so take the extra time to state
your case as clearly and completely as possible.

IMPORTANT: Each submission should be a single suggestion (not a list of
suggestions)

John Langhans
Microsoft Corporation
Supportability Program Manager
Microsoft Office PowerPoint for Windows
Microsoft Office Picture Manager for Windows

For FAQ's, highlights and top issues, visit the Microsoft PowerPoint
support center at: http://support.microsoft.com/default.aspx?pr=ppt
Search the Microsoft Knowledge Base at:
http://support.microsoft.com/default.aspx?pr=kbhowto

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top