Recent File List

H

Hal

Hello all,

I want to have a workbook check if its name is in the recent file list.

Please advise on how to use the RecentFile(s) classes to do this.

Private Sub Workbook_Open()
If workbookname is in recent file list Then
MsgBox ("Display Me!")
End If
End Sub

Thanks.
 
M

Mike H

Hi,

Something like this

myworkbook = "Book1.xlsx"
With ThisWorkbook
For i = 1 To Application.RecentFiles.Count
If Application.RecentFiles(i).Name = myworkbook Then
'do something
End If
Next i
End With

Mike
 
H

Hal

Thanks Mike,

I'll give this a try. After I posted I started to wonder if this was even
possible. Depending on when a document name gets added to the recent file
list.
 
C

Chip Pearson

Try something like

Private Sub Workbook_Open()
Dim S As String
Dim N As Long
With Application.RecentFiles
For N = 1 To .Count
If StrComp(Me.Name, .Item(N).Name, vbTextCompare) = 0 Then
MsgBox "In List"
Exit For
End If
Next N
End With
End Sub


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top