2

In Excel 2013, you just do it by going to File > open > Recent Workbooks > choose the first in the list.

But can this be done by code ? Seems easy enough to do, but i didn't find any clue, here or on the net.

note, i think i need the name + full path of the file , and then a simple workbooks.open Filename, will do.

Also note, no workbooks are opened at this time, and thisworkbook.name is not elligible (or it will loop infinitely to open himself).

i was thinking of something like

Dim a as Long Dim i as Long Dim Str as String a= Application.OpenworkbooksHistory.items.count For i=1 to a str = Application.OpenworkbooksHistory.items (i) if str<>thisworkbook.path & "\" & thisworkbook.name then workbooks.open str exit sub end if next i 

1 Answer 1

4

You'll find a collection of recent files in Application.RecentFiles

To open the last one just use Workbooks.open Application.REcentFiles(1)

Or you could loop through them if you want something more fancy:

For each rfile in application.recentfiles if instr(1, rfile.name, "poop") > 0 then Workbooks.open rfile.name end if next 
Sign up to request clarification or add additional context in comments.

1 Comment

excellent! thats excactly it. You forgot a .name on the 2nd line of your answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.