ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Restoring the Recently Used File List (https://www.excelbanter.com/excel-programming/348433-restoring-recently-used-file-list.html)

Peter Rooney

Restoring the Recently Used File List
 
Good morning, all,

One of my applications disables the recently used file list, but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list to an array,
then restore them later on?

Thanks in advance

Pete

chijanzen

Restoring the Recently Used File List
 
Peter:

Other method,delete ThisWorkbook.FullName in RecentFiles list

With ThisWorkbook
For Ndx = 1 To Application.RecentFiles.Count
If Application.RecentFiles(Ndx).Path = .FullName Then
Application.RecentFiles(Ndx).Delete
Exit For
End If
Next Ndx
End With

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, all,

One of my applications disables the recently used file list, but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list to an array,
then restore them later on?

Thanks in advance

Pete


Peter Rooney

Restoring the Recently Used File List
 
Good morning, ChiJanZen

Well, at least I understand the object collection that I need to refer to,
but I can't get it to work at the moment.

Even

MsgBox (Application.RecentFiles(1))

doesn't display an empty message box.

I'm stumped.

Pete


doesn't display anything - not even the messagebox

"chijanzen" wrote:

Peter:

Other method,delete ThisWorkbook.FullName in RecentFiles list

With ThisWorkbook
For Ndx = 1 To Application.RecentFiles.Count
If Application.RecentFiles(Ndx).Path = .FullName Then
Application.RecentFiles(Ndx).Delete
Exit For
End If
Next Ndx
End With

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, all,

One of my applications disables the recently used file list, but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list to an array,
then restore them later on?

Thanks in advance

Pete


chijanzen

Restoring the Recently Used File List
 
Peter:

doesn't display an empty message box.



MsgBox (Application.RecentFiles(1).Path)


or

Dim Recent As Variant

Sub test()
ReDim Recent(Application.RecentFiles.Count)
For Each f In Application.RecentFiles
Recent(I) = f.Path
I = I + 1
Next
' Application.RecentFiles.Maximum = 0
For I = 0 To UBound(Recent)
MsgBox Recent(I)
Next I
End Sub




--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, ChiJanZen

Well, at least I understand the object collection that I need to refer to,
but I can't get it to work at the moment.

Even

MsgBox (Application.RecentFiles(1))

doesn't display an empty message box.

I'm stumped.

Pete


doesn't display anything - not even the messagebox

"chijanzen" wrote:

Peter:

Other method,delete ThisWorkbook.FullName in RecentFiles list

With ThisWorkbook
For Ndx = 1 To Application.RecentFiles.Count
If Application.RecentFiles(Ndx).Path = .FullName Then
Application.RecentFiles(Ndx).Delete
Exit For
End If
Next Ndx
End With

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, all,

One of my applications disables the recently used file list, but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list to an array,
then restore them later on?

Thanks in advance

Pete


Peter Rooney

Restoring the Recently Used File List
 
ChiJanZen,

I'm quite a bit further on now, thanks to your help!

I have now successfully stored the items in the recently used file list to a
variable, and I can reference the array elements individually. What I now
want to do is first of all display them in a for each loop, then work towards
restoring them back from the array to the recently used file list once more.

However, I'm having some trouble doing this. Here's what I have:

Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count - 1) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used File
List")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " & UBound(RecentFileListArray))
End Sub

When I run my display macro, I get a "Subscript out of range" error.

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub


Any ideas what I'm doing wrong now, please?

Thanks in advance

Pete






"chijanzen" wrote:

Peter:

doesn't display an empty message box.



MsgBox (Application.RecentFiles(1).Path)


or

Dim Recent As Variant

Sub test()
ReDim Recent(Application.RecentFiles.Count)
For Each f In Application.RecentFiles
Recent(I) = f.Path
I = I + 1
Next
' Application.RecentFiles.Maximum = 0
For I = 0 To UBound(Recent)
MsgBox Recent(I)
Next I
End Sub




--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, ChiJanZen

Well, at least I understand the object collection that I need to refer to,
but I can't get it to work at the moment.

Even

MsgBox (Application.RecentFiles(1))

doesn't display an empty message box.

I'm stumped.

Pete


doesn't display anything - not even the messagebox

"chijanzen" wrote:

Peter:

Other method,delete ThisWorkbook.FullName in RecentFiles list

With ThisWorkbook
For Ndx = 1 To Application.RecentFiles.Count
If Application.RecentFiles(Ndx).Path = .FullName Then
Application.RecentFiles(Ndx).Delete
Exit For
End If
Next Ndx
End With

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, all,

One of my applications disables the recently used file list, but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list to an array,
then restore them later on?

Thanks in advance

Pete


chijanzen

Restoring the Recently Used File List
 
Peter:

try,

Dim RecentFileListArray As Variant
Option Base 1
Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used File
List ")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " & UBound(RecentFileListArray))
End Sub

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

ChiJanZen,

I'm quite a bit further on now, thanks to your help!

I have now successfully stored the items in the recently used file list to a
variable, and I can reference the array elements individually. What I now
want to do is first of all display them in a for each loop, then work towards
restoring them back from the array to the recently used file list once more.

However, I'm having some trouble doing this. Here's what I have:

Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count - 1) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used File
List")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " & UBound(RecentFileListArray))
End Sub

When I run my display macro, I get a "Subscript out of range" error.

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub


Any ideas what I'm doing wrong now, please?

Thanks in advance

Pete






"chijanzen" wrote:

Peter:

doesn't display an empty message box.



MsgBox (Application.RecentFiles(1).Path)


or

Dim Recent As Variant

Sub test()
ReDim Recent(Application.RecentFiles.Count)
For Each f In Application.RecentFiles
Recent(I) = f.Path
I = I + 1
Next
' Application.RecentFiles.Maximum = 0
For I = 0 To UBound(Recent)
MsgBox Recent(I)
Next I
End Sub




--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, ChiJanZen

Well, at least I understand the object collection that I need to refer to,
but I can't get it to work at the moment.

Even

MsgBox (Application.RecentFiles(1))

doesn't display an empty message box.

I'm stumped.

Pete


doesn't display anything - not even the messagebox

"chijanzen" wrote:

Peter:

Other method,delete ThisWorkbook.FullName in RecentFiles list

With ThisWorkbook
For Ndx = 1 To Application.RecentFiles.Count
If Application.RecentFiles(Ndx).Path = .FullName Then
Application.RecentFiles(Ndx).Delete
Exit For
End If
Next Ndx
End With

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, all,

One of my applications disables the recently used file list, but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list to an array,
then restore them later on?

Thanks in advance

Pete


Peter Rooney

Restoring the Recently Used File List
 
Good morning, ChiZanZen!

This works fine - all I now need to do is figure out how to get the values
stored in the array back into the Recently used file list - I'm not sure if
this is even possible, though.

I've used:

Sub RecentlyUsedFileListRestore()
On Error Resume Next

For NDX = LBound(RFLArray) To UBound(RFLArray)
Application.RecentFiles(NDX) = RFLArray(NDX)
Next NDX
Application.DisplayRecentFiles = True
End Sub

but it doesn't appear to work. I'm not sure if the use of
application.displayrecentfiles = true is affecting it and re-resetting the
list.

Anyway, thanks for your help and I'll persevere, though once again, any
thoughts would be greatly appreciated!

Regards

Pete

P.S. it's 09:26 here at the moment - what time is it where you are? I don't
want to keep you from your bed! :-)


"chijanzen" wrote:

Peter:

try,

Dim RecentFileListArray As Variant
Option Base 1
Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used File
List ")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " & UBound(RecentFileListArray))
End Sub

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

ChiJanZen,

I'm quite a bit further on now, thanks to your help!

I have now successfully stored the items in the recently used file list to a
variable, and I can reference the array elements individually. What I now
want to do is first of all display them in a for each loop, then work towards
restoring them back from the array to the recently used file list once more.

However, I'm having some trouble doing this. Here's what I have:

Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count - 1) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used File
List")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " & UBound(RecentFileListArray))
End Sub

When I run my display macro, I get a "Subscript out of range" error.

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub


Any ideas what I'm doing wrong now, please?

Thanks in advance

Pete






"chijanzen" wrote:

Peter:

doesn't display an empty message box.


MsgBox (Application.RecentFiles(1).Path)


or

Dim Recent As Variant

Sub test()
ReDim Recent(Application.RecentFiles.Count)
For Each f In Application.RecentFiles
Recent(I) = f.Path
I = I + 1
Next
' Application.RecentFiles.Maximum = 0
For I = 0 To UBound(Recent)
MsgBox Recent(I)
Next I
End Sub




--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, ChiJanZen

Well, at least I understand the object collection that I need to refer to,
but I can't get it to work at the moment.

Even

MsgBox (Application.RecentFiles(1))

doesn't display an empty message box.

I'm stumped.

Pete


doesn't display anything - not even the messagebox

"chijanzen" wrote:

Peter:

Other method,delete ThisWorkbook.FullName in RecentFiles list

With ThisWorkbook
For Ndx = 1 To Application.RecentFiles.Count
If Application.RecentFiles(Ndx).Path = .FullName Then
Application.RecentFiles(Ndx).Delete
Exit For
End If
Next Ndx
End With

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, all,

One of my applications disables the recently used file list, but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list to an array,
then restore them later on?

Thanks in advance

Pete


Norman Jones

Restoring the Recently Used File List
 
Hi Peter,

Try replacing:

Application.RecentFiles(NDX) = RFLArray(NDX)


with
Application.RecentFiles.Add Name:=RFLArray(NDX)


---
Regards,
Norman



"Peter Rooney" wrote in message
...
Good morning, ChiZanZen!

This works fine - all I now need to do is figure out how to get the values
stored in the array back into the Recently used file list - I'm not sure
if
this is even possible, though.

I've used:

Sub RecentlyUsedFileListRestore()
On Error Resume Next

For NDX = LBound(RFLArray) To UBound(RFLArray)
Application.RecentFiles(NDX) = RFLArray(NDX)
Next NDX
Application.DisplayRecentFiles = True
End Sub

but it doesn't appear to work. I'm not sure if the use of
application.displayrecentfiles = true is affecting it and re-resetting the
list.

Anyway, thanks for your help and I'll persevere, though once again, any
thoughts would be greatly appreciated!

Regards

Pete

P.S. it's 09:26 here at the moment - what time is it where you are? I
don't
want to keep you from your bed! :-)


"chijanzen" wrote:

Peter:

try,

Dim RecentFileListArray As Variant
Option Base 1
Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used
File
List ")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " &
UBound(RecentFileListArray))
End Sub

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To
UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub

--
???,???????
???,???????

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

ChiJanZen,

I'm quite a bit further on now, thanks to your help!

I have now successfully stored the items in the recently used file list
to a
variable, and I can reference the array elements individually. What I
now
want to do is first of all display them in a for each loop, then work
towards
restoring them back from the array to the recently used file list once
more.

However, I'm having some trouble doing this. Here's what I have:

Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count - 1) 'As
Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used
File
List")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " &
UBound(RecentFileListArray))
End Sub

When I run my display macro, I get a "Subscript out of range" error.

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To
UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub


Any ideas what I'm doing wrong now, please?

Thanks in advance

Pete






"chijanzen" wrote:

Peter:

doesn't display an empty message box.


MsgBox (Application.RecentFiles(1).Path)


or

Dim Recent As Variant

Sub test()
ReDim Recent(Application.RecentFiles.Count)
For Each f In Application.RecentFiles
Recent(I) = f.Path
I = I + 1
Next
' Application.RecentFiles.Maximum = 0
For I = 0 To UBound(Recent)
MsgBox Recent(I)
Next I
End Sub




--
???,???????
???,???????

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, ChiJanZen

Well, at least I understand the object collection that I need to
refer to,
but I can't get it to work at the moment.

Even

MsgBox (Application.RecentFiles(1))

doesn't display an empty message box.

I'm stumped.

Pete


doesn't display anything - not even the messagebox

"chijanzen" wrote:

Peter:

Other method,delete ThisWorkbook.FullName in RecentFiles list

With ThisWorkbook
For Ndx = 1 To Application.RecentFiles.Count
If Application.RecentFiles(Ndx).Path = .FullName Then
Application.RecentFiles(Ndx).Delete
Exit For
End If
Next Ndx
End With

--
???,???????
???,???????

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, all,

One of my applications disables the recently used file list,
but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list
to an array,
then restore them later on?

Thanks in advance

Pete




Peter Rooney

Restoring the Recently Used File List
 
Norman,

Spot on! Thank you VERY much, and if I don't get to bend your ear again this
year, have a great Christmas! :-)

Regards

Pete


"Norman Jones" wrote:

Hi Peter,

Try replacing:

Application.RecentFiles(NDX) = RFLArray(NDX)


with
Application.RecentFiles.Add Name:=RFLArray(NDX)


---
Regards,
Norman



"Peter Rooney" wrote in message
...
Good morning, ChiZanZen!

This works fine - all I now need to do is figure out how to get the values
stored in the array back into the Recently used file list - I'm not sure
if
this is even possible, though.

I've used:

Sub RecentlyUsedFileListRestore()
On Error Resume Next

For NDX = LBound(RFLArray) To UBound(RFLArray)
Application.RecentFiles(NDX) = RFLArray(NDX)
Next NDX
Application.DisplayRecentFiles = True
End Sub

but it doesn't appear to work. I'm not sure if the use of
application.displayrecentfiles = true is affecting it and re-resetting the
list.

Anyway, thanks for your help and I'll persevere, though once again, any
thoughts would be greatly appreciated!

Regards

Pete

P.S. it's 09:26 here at the moment - what time is it where you are? I
don't
want to keep you from your bed! :-)


"chijanzen" wrote:

Peter:

try,

Dim RecentFileListArray As Variant
Option Base 1
Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used
File
List ")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " &
UBound(RecentFileListArray))
End Sub

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To
UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub

--
???,???????
???,???????

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

ChiJanZen,

I'm quite a bit further on now, thanks to your help!

I have now successfully stored the items in the recently used file list
to a
variable, and I can reference the array elements individually. What I
now
want to do is first of all display them in a for each loop, then work
towards
restoring them back from the array to the recently used file list once
more.

However, I'm having some trouble doing this. Here's what I have:

Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count - 1) 'As
Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used
File
List")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " &
UBound(RecentFileListArray))
End Sub

When I run my display macro, I get a "Subscript out of range" error.

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To
UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub


Any ideas what I'm doing wrong now, please?

Thanks in advance

Pete






"chijanzen" wrote:

Peter:

doesn't display an empty message box.


MsgBox (Application.RecentFiles(1).Path)


or

Dim Recent As Variant

Sub test()
ReDim Recent(Application.RecentFiles.Count)
For Each f In Application.RecentFiles
Recent(I) = f.Path
I = I + 1
Next
' Application.RecentFiles.Maximum = 0
For I = 0 To UBound(Recent)
MsgBox Recent(I)
Next I
End Sub




--
???,???????
???,???????

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, ChiJanZen

Well, at least I understand the object collection that I need to
refer to,
but I can't get it to work at the moment.

Even

MsgBox (Application.RecentFiles(1))

doesn't display an empty message box.

I'm stumped.

Pete


doesn't display anything - not even the messagebox

"chijanzen" wrote:

Peter:

Other method,delete ThisWorkbook.FullName in RecentFiles list

With ThisWorkbook
For Ndx = 1 To Application.RecentFiles.Count
If Application.RecentFiles(Ndx).Path = .FullName Then
Application.RecentFiles(Ndx).Delete
Exit For
End If
Next Ndx
End With

--
???,???????
???,???????

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, all,

One of my applications disables the recently used file list,
but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list
to an array,
then restore them later on?

Thanks in advance

Pete





chijanzen

Restoring the Recently Used File List
 
Peter:

it's 17:58 here

first Run A0_RecentlyUsedFileListStore
and Run RecentlyUsedFileListRestore

Dim RecentFileListArray As Variant
Dim num As Integer
Option Base 1
Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count) 'As Variant
On Error Resume Next
For NDX = 1 To Application.RecentFiles.Count
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
'del RecentFiles
num = Application.RecentFiles.Maximum
Application.RecentFiles.Maximum = 0
End Sub

Sub RecentlyUsedFileListRestore()
Application.RecentFiles.Maximum = num
For NDX = LBound(RecentFileListArray) To UBound(RecentFileListArray)
Application.RecentFiles.Add Name:=RecentFileListArray(NDX)
Next NDX
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, ChiZanZen!

This works fine - all I now need to do is figure out how to get the values
stored in the array back into the Recently used file list - I'm not sure if
this is even possible, though.

I've used:

Sub RecentlyUsedFileListRestore()
On Error Resume Next

For NDX = LBound(RFLArray) To UBound(RFLArray)
Application.RecentFiles(NDX) = RFLArray(NDX)
Next NDX
Application.DisplayRecentFiles = True
End Sub

but it doesn't appear to work. I'm not sure if the use of
application.displayrecentfiles = true is affecting it and re-resetting the
list.

Anyway, thanks for your help and I'll persevere, though once again, any
thoughts would be greatly appreciated!

Regards

Pete

P.S. it's 09:26 here at the moment - what time is it where you are? I don't
want to keep you from your bed! :-)


"chijanzen" wrote:

Peter:

try,

Dim RecentFileListArray As Variant
Option Base 1
Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used File
List ")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " & UBound(RecentFileListArray))
End Sub

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

ChiJanZen,

I'm quite a bit further on now, thanks to your help!

I have now successfully stored the items in the recently used file list to a
variable, and I can reference the array elements individually. What I now
want to do is first of all display them in a for each loop, then work towards
restoring them back from the array to the recently used file list once more.

However, I'm having some trouble doing this. Here's what I have:

Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count - 1) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used File
List")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " & UBound(RecentFileListArray))
End Sub

When I run my display macro, I get a "Subscript out of range" error.

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub


Any ideas what I'm doing wrong now, please?

Thanks in advance

Pete






"chijanzen" wrote:

Peter:

doesn't display an empty message box.


MsgBox (Application.RecentFiles(1).Path)


or

Dim Recent As Variant

Sub test()
ReDim Recent(Application.RecentFiles.Count)
For Each f In Application.RecentFiles
Recent(I) = f.Path
I = I + 1
Next
' Application.RecentFiles.Maximum = 0
For I = 0 To UBound(Recent)
MsgBox Recent(I)
Next I
End Sub




--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, ChiJanZen

Well, at least I understand the object collection that I need to refer to,
but I can't get it to work at the moment.

Even

MsgBox (Application.RecentFiles(1))

doesn't display an empty message box.

I'm stumped.

Pete


doesn't display anything - not even the messagebox

"chijanzen" wrote:

Peter:

Other method,delete ThisWorkbook.FullName in RecentFiles list

With ThisWorkbook
For Ndx = 1 To Application.RecentFiles.Count
If Application.RecentFiles(Ndx).Path = .FullName Then
Application.RecentFiles(Ndx).Delete
Exit For
End If
Next Ndx
End With

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, all,

One of my applications disables the recently used file list, but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list to an array,
then restore them later on?

Thanks in advance

Pete


Peter Rooney

Restoring the Recently Used File List
 
Hi, ChiJanZen!

Yep, it was the recentfiles.add bit that worked it.

Thanks VERY much for your help. I have a 14:00 meeting at which I needed to
be able to demonstrate this and now I can! :-)))))

Thanks for your help on this and recently - I wish you and your family a
good Christmas and New Year.

Regards

Pete



"chijanzen" wrote:

Peter:

it's 17:58 here

first Run A0_RecentlyUsedFileListStore
and Run RecentlyUsedFileListRestore

Dim RecentFileListArray As Variant
Dim num As Integer
Option Base 1
Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count) 'As Variant
On Error Resume Next
For NDX = 1 To Application.RecentFiles.Count
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
'del RecentFiles
num = Application.RecentFiles.Maximum
Application.RecentFiles.Maximum = 0
End Sub

Sub RecentlyUsedFileListRestore()
Application.RecentFiles.Maximum = num
For NDX = LBound(RecentFileListArray) To UBound(RecentFileListArray)
Application.RecentFiles.Add Name:=RecentFileListArray(NDX)
Next NDX
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, ChiZanZen!

This works fine - all I now need to do is figure out how to get the values
stored in the array back into the Recently used file list - I'm not sure if
this is even possible, though.

I've used:

Sub RecentlyUsedFileListRestore()
On Error Resume Next

For NDX = LBound(RFLArray) To UBound(RFLArray)
Application.RecentFiles(NDX) = RFLArray(NDX)
Next NDX
Application.DisplayRecentFiles = True
End Sub

but it doesn't appear to work. I'm not sure if the use of
application.displayrecentfiles = true is affecting it and re-resetting the
list.

Anyway, thanks for your help and I'll persevere, though once again, any
thoughts would be greatly appreciated!

Regards

Pete

P.S. it's 09:26 here at the moment - what time is it where you are? I don't
want to keep you from your bed! :-)


"chijanzen" wrote:

Peter:

try,

Dim RecentFileListArray As Variant
Option Base 1
Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used File
List ")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " & UBound(RecentFileListArray))
End Sub

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

ChiJanZen,

I'm quite a bit further on now, thanks to your help!

I have now successfully stored the items in the recently used file list to a
variable, and I can reference the array elements individually. What I now
want to do is first of all display them in a for each loop, then work towards
restoring them back from the array to the recently used file list once more.

However, I'm having some trouble doing this. Here's what I have:

Sub A0_RecentlyUsedFileListStore()
ReDim RecentFileListArray(Application.RecentFiles.Count - 1) 'As Variant
On Error Resume Next
MsgBox (Application.RecentFiles.Count & " file(s) in Recently Used File
List")
For NDX = 1 To Application.RecentFiles.Count
MsgBox (Application.RecentFiles(NDX).Name)
RecentFileListArray(NDX) = Application.RecentFiles(NDX).Name
Next
MsgBox (LBound(RecentFileListArray) & " " & UBound(RecentFileListArray))
End Sub

When I run my display macro, I get a "Subscript out of range" error.

Sub A0_RecentlyUsedFileListDisplay()
Dim Counter As Integer
For Counter = LBound(RecentFileListArray) To UBound(RecentFileListArray)
MsgBox (RecentFileListArray(Counter))
Next
End Sub


Any ideas what I'm doing wrong now, please?

Thanks in advance

Pete






"chijanzen" wrote:

Peter:

doesn't display an empty message box.


MsgBox (Application.RecentFiles(1).Path)


or

Dim Recent As Variant

Sub test()
ReDim Recent(Application.RecentFiles.Count)
For Each f In Application.RecentFiles
Recent(I) = f.Path
I = I + 1
Next
' Application.RecentFiles.Maximum = 0
For I = 0 To UBound(Recent)
MsgBox Recent(I)
Next I
End Sub




--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, ChiJanZen

Well, at least I understand the object collection that I need to refer to,
but I can't get it to work at the moment.

Even

MsgBox (Application.RecentFiles(1))

doesn't display an empty message box.

I'm stumped.

Pete


doesn't display anything - not even the messagebox

"chijanzen" wrote:

Peter:

Other method,delete ThisWorkbook.FullName in RecentFiles list

With ThisWorkbook
For Ndx = 1 To Application.RecentFiles.Count
If Application.RecentFiles(Ndx).Path = .FullName Then
Application.RecentFiles(Ndx).Delete
Exit For
End If
Next Ndx
End With

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Peter Rooney" wrote:

Good morning, all,

One of my applications disables the recently used file list, but when I
re-enable it, all its entries are lost.

Is there any way in which I can store the filenames in the list to an array,
then restore them later on?

Thanks in advance

Pete



All times are GMT +1. The time now is 03:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com