+ Reply to Thread
Results 1 to 2 of 2

VBA opening most recent file "pdf" in folder

  1. #1
    Registered User
    Join Date
    11-05-2018
    Location
    Prague
    MS-Off Ver
    16.18
    Posts
    8

    VBA opening most recent file "pdf" in folder

    Hello guys,

    I would like to open most recent pdf in the folder as folderPath. But unfortunately the pdf file is opened in excel. Is it possible to open it automatically in Adobe Acrobat XI Pro ?

    Thank you for answer

    Sub openLastModified()

    Dim folderPath As String, tableName As String, latestTblName As String
    Dim latestModified As Date, modifiedDate As Date

    folderPath = "C:\FASE\3000_ Receiv.....\"

    tableName = Dir(folderPath & "*.pdf")

    Do While tableName <> vbNullString
    modifiedDate = FileDateTime(folderPath & tableName)
    If latestModified < modifiedDate Then
    latestModified = modifiedDate
    latestTblName = tableName
    End If
    tableName = Dir()
    Loop

    Workbooks.Open folderPath & latestTblName

    End Sub

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: VBA opening most recent file "pdf" in folder

    Try to figure out something from here:

    Please Login or Register  to view this content.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. """default folder in get open file"""
    By daboho in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-31-2017, 09:40 AM
  2. Opening the most recent file saved to a folder
    By athyeh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2015, 08:50 PM
  3. [SOLVED] Script to save to folder in "v:\dept2", confirm file saved, then delete from "v:\dept1"
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2014, 11:42 AM
  4. Opening up workbooks in a folder called "days"
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-16-2014, 09:00 PM
  5. Macro For opening Most recent file in folder
    By dtaganovic16 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-13-2012, 12:00 PM
  6. Saving a file to a "YYYY" and "MMM" folder
    By hriggs in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-10-2008, 07:00 AM
  7. "Folder Select" Dialogue - Opening multiple files from selected folder
    By Rob in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2005, 10:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1