start file

T

Terry

MS Office XP Pro'
Win98SE

How may I start Excel with previously opened excel file please.
In Word I add..../mFile1...but does not work for Excel.

TIA
 
T

Terry

Sorry...I may have not described enough.....Now when I hit my Excel shortcut
it opens a BLANK worksheet.
With Word I have simply configured the shortcut to start with previously
opened file.
I am just lazy really.....don't blame me for that LOL.

Terry
 
D

Dave Peterson

You could create a helper workbook and store it in your XLStart folder.

Whenever excel starts up, it'll open this helper workbook--and that workbook
will open the topmost workbook on your MRU (most recently used) list.

Option Explicit
Sub auto_open()

Dim myFileName As String
Dim testStr As String
Dim FileNameIsOk As Boolean
Dim iCtr As Long

FileNameIsOk = False
For iCtr = 1 To Application.RecentFiles.Count
myFileName = Application.RecentFiles.Item(iCtr).Path
If LCase(myFileName) <> LCase(ThisWorkbook.FullName) Then
testStr = ""
On Error Resume Next
testStr = Dir(myFileName)
On Error GoTo 0
If testStr <> "" Then
'found one
Workbooks.Open Filename:=myFileName
MsgBox "Opened " & myFileName
FileNameIsOk = True
Exit For
End If
End If
Next iCtr

If FileNameIsOk = False Then
MsgBox "No MRU files found!"
End If

'ThisWorkbook.Close savechanges:=False

End Sub


After you test it, uncomment that last line and the workbook will close after it
does its work--but save it the way you want. It closes itself without saving.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
A

Andy

You could create a helper workbook and store it in your XLStart folder.

That's nice Dave, thanks. Once again I pick up something handy while
hanging around this newsgroup.

Instead of storing it in my XLStart folder, I made a shortcut to it on my
desktop - I only want to open my last file sometimes.

I also added:

Application.RecentFiles(1).Delete
Application.RecentFiles.Maximum = 9

So the helper workbook wouldn't show up in the MRU list.


Andy
 
Top