Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am opening files from within an excel workbook:
Note: vOPen and vPassword are hard coded in the workbook and I save the cell values to the variables and then on before double click I do this to open the selected file: Workbooks.Open Filename:=vOpen, Password:=vPassword, UpdateLinks:=3 The issue is the opened file is not added to the most recent opened under Files on the Menu. Is there code that would add the file to the list? Thanks for your help. Steven |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware ' Original idea by Dana DeLouis ' Removes non-existent files from the Recent Files List on the File Menu. ' Adds the names of any open & saved workbooks to the list. ' Maximum is nine names. '----------------------------------------------------- Sub RecentFilesAddToList() 'Created Jan 09, 2002 - Jim Cone - San Francisco, USA On Error GoTo FileHandler Dim NewFiles As Byte Dim N As Long Dim FileCount As Long Dim MsgText As String Dim AddText As String Dim ListOfFiles() As String Dim FileFlag As Boolean Dim WB As Excel.Workbook Application.DisplayRecentFiles = True Application.RecentFiles.Maximum = 9 RecentFilesCleanUp AddText 'Call Sub With Application.RecentFiles 'Determined after invalid file names are removed in called sub FileCount = .Count If FileCount Then ReDim ListOfFiles(1 To FileCount) For N = 1 To FileCount ListOfFiles(N) = .Item(N).Path Next 'N End If For Each WB In Workbooks If Len(WB.Path) Then For N = 1 To FileCount 'Compare the text after the last path separator to the workbook name. If Dir(ListOfFiles(N)) = WB.Name Then FileFlag = True Exit For End If Next 'N If Not FileFlag Then .Add Name:=WB.FullName MsgText = MsgText & " " & Chr$(34) & WB.Name & Chr$(34) & " " & vbCr NewFiles = NewFiles + 1 Else FileFlag = False End If End If 'Only nine names allowed in list If NewFiles 8 Then Beep Exit For End If Next 'WB .Maximum = .Maximum End With 'Application.RecentFiles Erase ListOfFiles If NewFiles = 0 Then If Len(AddText) Then MsgText = "No workbook file names were added. " _ Else MsgText = "No changes were made to the file list. " ElseIf NewFiles = 1 Then 'Remove the carriage return MsgText = "Workbook " & Left$(MsgText, Len(MsgText) - 1) & "was added. " Else MsgText = "These workbook names were added: " & vbCr & MsgText End If MsgBox MsgText & AddText, vbInformation, " Recent Files List - Refresh" Set WB = Nothing Exit Sub FileHandler: Beep Set WB = Nothing End Sub '----------------------------------------------------- 'Called by RecentFilesAddToList '----------------------------------------------------- Sub RecentFilesCleanUp(ByRef MoreText As String) 'Created Jan 09, 2002 - Jim Cone - San Francisco, USA Dim N As Long Dim BadFiles As Byte For N = Application.RecentFiles.Count To 1 Step -1 With Application.RecentFiles(N) On Error Resume Next 'Does not work on floppy drive??? If Len(Dir(.Path)) = 0 Then On Error GoTo 0 .Delete BadFiles = BadFiles + 1 End If End With Next ' N If BadFiles = 1 Then MoreText = vbCr & "One invalid file name deleted. " ElseIf BadFiles 1 Then MoreText = vbCr & BadFiles & " invalid file names deleted. " End If End Sub '----------------------------------------------------- "Steven" wrote in message I am opening files from within an excel workbook: Note: vOPen and vPassword are hard coded in the workbook and I save the cell values to the variables and then on before double click I do this to open the selected file: Workbooks.Open Filename:=vOpen, Password:=vPassword, UpdateLinks:=3 The issue is the opened file is not added to the most recent opened under Files on the Menu. Is there code that would add the file to the list? Thanks for your help. Steven |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Look in excel vba help for the recentfiles collection. It has an add method
Also see the recentfile object. Also Application.DisplayRecentFiles -- Regards, Tom Ogilvy "Steven" wrote in message ... I am opening files from within an excel workbook: Note: vOPen and vPassword are hard coded in the workbook and I save the cell values to the variables and then on before double click I do this to open the selected file: Workbooks.Open Filename:=vOpen, Password:=vPassword, UpdateLinks:=3 The issue is the opened file is not added to the most recent opened under Files on the Menu. Is there code that would add the file to the list? Thanks for your help. Steven |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Open Form when file opened | Excel Discussion (Misc queries) | |||
Can't open a file I just opened the day before. | Excel Discussion (Misc queries) | |||
cannot open the excel file, the file is already opened | Excel Discussion (Misc queries) | |||
Bug when macro tries to open allready opened file | Excel Programming | |||
How set file open path to filepath of file opened with Explorer ? | Excel Programming |