Re: open latest file



On Jan 14, 3:31 pm, "ekkehard.horner" <ekkehard.hor...@xxxxxxxx>
wrote:
JMageei...@xxxxxxxxx schrieb:> On Jan 14, 3:09 pm, "ekkehard.horner" <ekkehard.hor...@xxxxxxxx>
wrote:
JMageei...@xxxxxxxxx schrieb:

Is it possible to open the latest file using vbscript.
I have a directory that has a few powerpoint presentations in it. I
would like the script to automatically open the newest one.
I hope this

   Const cdtFirst = #1/1/100#

==========================================>>    Dim sFolder  : sFolder    = ".\"

==========================================



   Dim oFS      : Set oFS    = CreateObject( "Scripting..FileSystemObject" )
   Dim dtLatest : dtLatest   = cdtFirst
   Dim sExt     : sExt       = "ppt" ' not entirely sure about this extension
   Dim oLFile   : Set oLFile = Nothing
   Dim oFile
   For Each oFile in oFS.GetFolder( sFolder ).Files
       If sExt = LCase( oFS.GetExtensionName( oFile.Name ) ) Then
          If dtLatest < oFile.DateLastAccessed Then ' maybe DateCreated/DateLastModified
             dtLatest = oFile.DateLastAccessed
             Set oLFile = oFile
          End If
       End If
   Next
   If oLFile Is Nothing Then
      WScript.Echo "No file with extension", sExt, "found."
   Else
      WScript.Echo "found", oLFile.Name, oLFile.DateLastAccessed
   End If

will help you finding the file. I assume you could use WSHell.Run or
.Execute to start Powerpoint with the oLFile.Path as parameter - but
as I don't use PP, I can't help you in this regard.

Where do I enter the path?- Hide quoted text -

- Show quoted text -

I keep getting an error stating that the system cannot find the file
specified.
Line 19 Char. 3
.



Relevant Pages

  • Re: open latest file
    ... I have a directory that has a few powerpoint presentations in it. ...    For Each oFile in oFS.GetFolder.Files ... I keep getting an error stating that the system cannot find the file ...
    (microsoft.public.scripting.vbscript)
  • Re: open latest file
    ... would like the script to automatically open the newest one. ...    For Each oFile in oFS.GetFolder(sFolder).Files ...
    (microsoft.public.scripting.vbscript)
  • Re: open latest file
    ... would like the script to automatically open the newest one. ...    For Each oFile in oFS.GetFolder(sFolder).Files ...
    (microsoft.public.scripting.vbscript)
  • Re: scripting newb
    ... I was able to hobble this together from another script posted by Dan ... Dim strSearch, strAdsPath, strServerName 'from search script ...     'Prompt for search criteria ... computerName, samAccountName, givenName, sn, AdsPath ...
    (microsoft.public.scripting.vbscript)
  • Re: 2 scripts w errors on compacting access db
    ... Script 1: ... This old newsgroup thread included code to compact an Access database: ... ' You must provide a path to the Access MDB which will be compacted ...     On Error GoTo 0 ...
    (microsoft.public.scripting.vbscript)