View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
FinChase FinChase is offline
external usenet poster
 
Posts: 21
Default Open existing file

I am trying to open existing files in Excel. I am using the GetOpenFilename
method to select the files.

Sub SelectBookToOpen()

Dim FileToOpen As Variant
Dim MyPath As String
Dim Wb As Workbook

MyPath = "T:\Archive"
ChDrive "T"
ChDir MyPath

FileToOpen = Application.GetOpenFilename("Excel Files (*.xls), *.xls", , _
"Please select both previous and current weeks' Data Archives", , True)

If FileToOpen < False Then
Set Wb = Workbooks.Open(FileToOpen)
Else
Exit Sub
End If

End Sub

Everything works fine until I actually select a file and click Open. Then I
get a data mismatch error on this line: If FileToOpen < False Then

What am I doing wrong?
Thanks, Lee