Steve Rindsberg said:
If you recall the problems you ran into, I'd like to know about them, whether
it was with the code on the site or the way it was explained. I'd like to
spare others the same problems. Thanks.
Cool. [grinning and handing out grains of salt, just in case]
Off the top of my head, the biggest problem was with getting the
actual file. I actually had some notes to work off of for this:
Here's the original code:
Set oPic = ActiveWindow.Selection.SlideRange.Shapes.AddPicture _
(FileName:=strFileSpec, LinkToFile:=msoFalse,
SaveWithDocument:=msoTrue, _
Left:=0, Top:=0, Width:=100, Height:=100)
This generated a run-time error: "Selection (unknown member): Invalid
request. Nothing appropriate is currently selected."
At this point, the strFileSpec variable is the path and wildcard (i.e.
"c:\testpics\*.jpg"), which I figured was too vague. So, I added code
to remove the wildcard part of the string ("*.jpg") and replace it
with the unique filename that changes with each iteration of the loop.
(See my previous post for the pertinent code. I tried to document it
well enough to be self-explanatory.)
....Looking at the code myself, I'm seeing that I'm re-stripping the
wildcard code WITHIN the loop, which is unnecessary. I shoulda put
that before the loop instead.
Still coding, of course. I'm still
at a point where I'm trying to get each planned step to WORK. I'll
optimize later.
I also included code to place the name of the file at the bottom of
the slide. To make this easier, I added a slide number variable
(SlideNum) so I could more easily identify and add a textbox to the
correct slide. Without this variable, I was having a devil of a time
coming up with the correct syntax for "on the slide I just worked on,
darn it!"
'Add filename to slide in a text box
'(as wide as a slide, centered at the bottom)
Set ThisSlide = ActivePresentation.Slides(SlideNum)
Set FilenameBox = ThisSlide.Shapes.AddTextbox(msoTextOrientationHorizontal,
_
12, 502, 700, 50)
With FilenameBox
.TextFrame.TextRange.Text = strTemp
.TextFrame.TextRange.Font.Color.SchemeColor = ppForeground
.TextFrame.TextRange.Paragraphs(Start:=1, _
Length:=1).ParagraphFormat.Alignment = ppAlignCenter
.TextFrame.TextRange.Font.Name = "Courier New"
.TextFrame.TextRange.Font.Bold = True
End With
Just in case anyone's wondering: My changes to the original code from
the PPT FAQ are not copyrighted in any way. I'm posting them here so
anyone can use them. VBA is hard enough to work with in Excel or
Access... but it's been a downright pain in my butt with Powerpoint.
If I can alleviate just one person's similar pain... I've accomplished
something good.
Dennis