Howdy all,
Is there room for one more?
Option Explicit
Dim Halt As Boolean
Sub OpenSingleFile()
Dim FileToOpen As String
Dim wb As Workbook
ChDir "C:\Documents and Settings\" & Environ("UserName") & "\My Documents\"
FileToOpen = Application.GetOpenFilename("Excel Files (*.xl*), *.xl*")
If UCase(FileToOpen) = "FALSE" Then
Halt = True
MsgBox "You need to select a file"
ChDir "C:\"
Exit Sub
End If
If Not WorkbookIsOpen(FileToOpen) Then
Set wb = Workbooks.Open(FileToOpen)
Else
Set wb = Workbooks(Mid$(FileToOpen, InStrRev(FileToOpen, "\") + 1))
End If
'code goes here for the file that is selected and opened.
End Sub
Function WorkbookIsOpen(wbFullName As String) As Boolean
On Error Resume Next
WorkbookIsOpen = Workbooks(Mid$(wbFullName, InStrRev(wbFullName, "\") + 1)).FullName = wbFullName
End Function