Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function for "insert slides from files"

Status
Not open for further replies.
Take a look at the InsertFromFile method of the Slides collection.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks. From your reply, I found this:
.Slides.InsertFromFile "c:\PPTOutline.doc", 1

but now I have the problem that it doesn't keep the source formatting which is a box I can check in the "insert slides from file" dialog box. Any idea how to keep its source formatting so the slide doesn't get all screwed up?

thanks
 
looks like I just need to:
ActivePresentation.ApplyTemplate "c:\PPTOutline.doc"

 
here is a macro to find all the files in a directory (and subdirectories) and insert their first slide into the present doc. (I wish I new how to insert all slides)

Sub insert()
'
' Macro recorded 10/18/2004 by myname
'
ActivePresentation.ApplyTemplate "C:\Documents and Settings\myname\Desktop\delete\AMR Leased Line Backup -- Overview and Definition.ppt"

Dim strFileSearch() As Variant
Dim intFileCount As Integer
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Documents and Settings\myname\Desktop\delete" ' StrDirectory_To_Search_For_files
.FileName = "*.ppt" 'type of file to search for
.SearchSubFolders = True
If .Execute > 0 Then

intFileCount = .FoundFiles.Count
ReDim strFileSearch(intFileCount)

For i = .FoundFiles.Count To 1 Step -1
Debug.Print .FoundFiles.Count
strFileSearch(i) = .FoundFiles(i)
ActivePresentation.Slides.InsertFromFile .FoundFiles(i), 0, 1
Next i
Else
MsgBox "There were no files found", vbInformation + vbOKOnly
End If
End With

End Sub
 
ActivePresentation.Slides.InsertFromFile _
filename, 0, 1

inserts all the slides for me. What version are you using?



Gerry
 
Ooops. Sorry, I posted in your other thread. If possible, try and keep a thread as one, rather than multi-posting for the same effort.

You could also use FileSystemObject. You must make a Reference to Microsoft Scripting Runtime. What version are you using? Because the following pulls ALL the sildes, from ALL the .PPT files. Not just the first slide. XP (2002)

Code:
Sub InsertAllSlides()
Dim fso As Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim fil As Scripting.File

Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder("c:\temp")

For Each fil In fld.Files
If Right(fil.ShortName, 3) = UCase("ppt") Then
 ActivePresentation.Slides.InsertFromFile _
   fil.Path, 0, 1
End If
Next
Set fld = Nothing
Set fso = Nothing
End Sub

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top