So...
 I am working on some code in Excel to create some automation.  My goal is 
for a macro to run and create a new PowerPoint presentation and to then 
open  5 PowerPoint slides in the excel sheet and place them into the 
presentation in the order they are listed in the excel file.   I have an 
excel file with 5 hyperlinks (A1:A5) and no other info in the file.  The 
hyperlinks are locations on a server of PowerPoint slides all in different 
locations (Z:\Production\Marty\0001\4SQ\Test.pptx).

So I have been working to do this through the Excel file and the 
conversation came up that this could be done in PowerPoint too with the use 
of VBA.  Either way I would like to see it work in Excel and PowerPoint for 
learning and experience.   

Where I am stuck.  The code partially works but it is not inserting the 
slides.  It generates a new PowerPoint presentation but none of the slides 
show up, only a a new blank slide.  The code is posted below.  Let me know 
if anyone has some thoughts. Thanks for viewing.   

 I have also been working with another individual, gary, from the excel 
group (here is a link to my original post): 
https://groups.google.com/forum/#!topic/microsoft.public.excel.programming/gT7ngWeCCzA
 

Code for the whole module (three different macros): 

Option Explicit 

Const sPath$ = "C:\Users\Marty\Documents\" 

Sub CreatePowerPoint() 
  Dim vList, n& 
  Dim vFile 

  vList = ActiveSheet.Range("A1:A5") 
  On Error GoTo Cleanup 
  'Automate a new instance of PowerPoint 
  With CreateObject("PowerPoint.
Application") 
    .Visible = True 
    'Add a new presentation 
    With .Presentations.Add 
      'Insert the slides into the presentation 
      For n = LBound(vList) To UBound(vList) 
        .slides.InsertFromFile vFile(n, 1), .slides.Count + 1 
      Next 'n 
    End With '.Presentations.Add 
  End With 'CreateObject 
Cleanup: 
End Sub 

Sub InsertSlidesFromFile() 
' Inserts slides from a list of PPTs stored in a txt file 
  Dim vList, n& 
  Dim vFile 

  vList = Split(ReadTextFile(sPath & "auto.txt"), vbCrLf) 
  On Error GoTo Cleanup 
  'Add a new presentation 
  With Application.Presentations.Add 
    'Insert the slides into the presentation 
    For n = LBound(vList) To UBound(vList) 
      .slides.InsertFromFile sPath & vFile(n), .slides.Count + 1 
    Next 'n 
  End With 'Application.Presentations.Add 
Cleanup: 
End Sub 

Sub InsertSlidesFromFolder() 
' Inserts slides from a list of PPTs stored in a txt file 
  Dim vFile, n& 

  vFile = Dir(sPath) 
  On Error GoTo Cleanup 
  'Add a new presentation 
  With Application.Presentations.Add 
    'Insert the slides into the presentation 
    Do While Len(vFile) 
      .slides.InsertFromFile sPath & vFile, .slides.Count + 1 
      vFile = Dir() 
    Loop 
  End With 'Application.Presentations.Add 
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()


Thanks for viewing.  Cheers

Marty

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to