Hi All,
I have the below macro within my excel file and it is kicked off as soon as my workbook opens. Normally this seems to work fine, however when I schedule the excel to be kicked of using windows task scheduler (either directly or via batch file) i get an error on the " PPT.Presentations.Open" line that powerpoint could not open the file.
There are other macros which run before this that require opening and closing additional excel files, those run fine, just run into this problem with ppt. Any ideas what causes this??
Sub PPT_Update()
Dim FilePath As String
Dim pptName As String
Dim PPT As Object
' for logging
Dim logfso * * *As FileSystemObject
Dim logTxtStr * As TextStream
Dim logFile * * As String
Set logfso = New FileSystemObject
logFile = ThisWorkbook.Path & "\" & "Execution Logs\" & Format(Date, "YYYY.MM.DD") & "_Log.txt"
Set logTxtStr = logfso.OpenTextFile(logFile, ForAppending, True)
logTxtStr.WriteLine Now & " - Begin Powerpoint Update"
On Error GoTo Err_handler
FilePath = ThisWorkbook.Path
pptName = "MSTR - UK Payday Pitch.pptm"
Set PPT = CreateObject("PowerPoint.Application")
'With PPT
logTxtStr.WriteLine Now & " - create ppt object"
PPT.Presentations.Open (FilePath & "\" & pptName)
logTxtStr.WriteLine Now & " - Opened PowerPoint File"
PPT.Run "MSTR - UK Payday Pitch.pptm!Module1.Update_links"
logTxtStr.WriteLine Now & " - Updated Links in Powerpoint"
PPT.ActivePresentation.SaveAs FilePath & "\UK - Weekly Ops Pitch Presentations\" & "UK - PDL Weekly Ops Pitch " & Format(Date, "MM.DD.YYYY") & ".pptx", FileFormat:=ppSaveAsOpenXMLPicturePresentation
logTxtStr.WriteLine Now & " - Saved ppt pict presentation"
PPT.Quit
logTxtStr.WriteLine Now & " - quit ppt"
Set PPT = Nothing
'End With
logTxtStr.WriteBlankLines 1
logTxtStr.Close
Exit Sub
Err_handler:
LogError Err, "ppt_update"
logTxtStr.WriteLine Now & " - ERROR - Check Error Log"
logTxtStr.WriteBlankLines 1
logTxtStr.Close
End Sub
Bookmarks