View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Marty Girvan Marty Girvan is offline
external usenet poster
 
Posts: 23
Default Macro to generate powerpoint slides

Thanks again. I started working from the PPT macro first as it makes more sense. However, I am running into a issue. I created a txt file that only contains a list of paths for all the files (150 files. The files are stored in different locations throughout the server. The txt file only contains the file paths. Here is my (your) code:



Sub auto()

' Inserts slides from a list of PPTs stored in a txt file
Dim vList, n&
Dim vFile
Const sPath$ = "C:\Users\Marty\Documents"

'auto.txt is the file with the hyperlinks
vList = Split(ReadTextFile(sPath & "auto.txt"), vbCrLf)
On Error GoTo Cleanup
With Application
For n = LBound(vList) To UBound(vList)
'Add a new slide where we will open the file (hyperlink)
With .Presentations.Add
'Insert the files into the slide
.Slides.InsertFromFile vFile(n), .Slides.Count + 1
End With '.Presentations.Add
Next 'n
End With 'Application
Cleanup:
End Sub

Function ReadTextFile$(Filename$)


'Reads large amounts of data from a text file in one single step.
Dim iNum%
On Error GoTo ErrHandler
iNum = FreeFile(): Open Filename For Input As #iNum
ReadTextFile = Space$(LOF(iNum))
ReadTextFile = Input(LOF(iNum), iNum)

ErrHandler:
Close #iNum: If Err Then Err.Raise , Err.Number, , Err.Description
End Function 'ReadTextFile()


I am getting a File Not Found when I debug. The argument looks valid but i am not sure why it is not finding the file. The error is on line 53' which is this line of code:

" Close #iNum: If Err Then Err.Raise , Err.Number, , Err.Description"

Any thoughts.

Also, I did play with the excel code a bit and it generates the PowerPoint presentation and the first slide, but it does not open the files. Here is the code I using:

Sub Run()
Dim vList, n&
Dim vFile

vList = ActiveSheet.Range("A1:A5")
On Error GoTo Cleanup
'Automate a new instance of PowerPoint
With CreateObject("PowerPoint.Application")
'Make a presentation in PowerPoint
.Visible = True

For n = LBound(vList) To UBound(vList)
'Add a new slide from the file
With .Presentations.Add
'Insert the slide into the presentation
.slides.InsertFromFile vFile(n, 1), .slides.Count + 1
End With '.Presentations.Add
Next 'n
End With 'CreateObject
Cleanup:


End Sub



Thanks again. I would like to try and get both the excel code working and the PPT code so that I can hand some of these projects over to others for them to run and can automate some of the daily processes. Thanks again, it is much appreciated and fun to learn. :)

Marty