Mona:
It is hard to tell from your issue, but I would assign a macro to the command button that uses the Windows API GetOpenFileName (I have found this safer and more flexible that the Excel Application.GetOpenFilename).
Here is the function definition and related Type def, followed by a code sample. Please note: I did not include all the variable definitions in the code sample. Basicially the Windows API call lets the user navigate anywhere to select a file and if they do (and click OK) the filename is returned. You can read about the API call on the Microsoft site:
http://msdn.microsoft.com/en-us/library/ms646927.aspx
Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Type OPENFILENAME
lngGOFStructSize As Long
lngGOFOwner As Long
lngGOFInstance As Long
strGOFFilter As String
strGOFCustomFilter As String
lngGOFMaxCustFilter As Long
lngGOFFilterIndex As Long
strGOFFile As String
lngGOFMaxFile As Long
strGOFFileTitle As String
lngGOFMaxFileTitle As Long
strGOFInitialDir As String
strGOFTitle As String
lngGOFFlags As Long
intGOFFileOffset As Integer
intGOFFileExtension As Integer
strGOFDefExt As String
lngGOFCustData As Long
lngGOFHook As Long
strGOFTemplateName As String
End Type
Sample code (without variable declarations):
'***
'* . get name (and location) of Test Data Workbook
'***
OpenFile.lngGOFStructSize = Len(OpenFile)
OpenFile.strGOFFilter = "(Test_Data*.XLS*)" & Chr(0) & _
"Test_Data*.XLS*" & Chr(0)
OpenFile.lngGOFFilterIndex = 1
OpenFile.strGOFFile = String(257, 0)
OpenFile.lngGOFMaxFile = Len(OpenFile.strGOFFile) - 1
OpenFile.lngGOFMaxFileTitle = OpenFile.lngGOFMaxFile
OpenFile.strGOFInitialDir = strDataPath
OpenFile.strGOFTitle = "Open Test Data Workbook"
OpenFile.lngGOFFlags = 0
Application.ScreenUpdating = True
lngReturn = GetOpenFileName(OpenFile)
Application.ScreenUpdating = False
If lngReturn = 0 Then
strMsg = "Open CMA Data Workbook CANCELLED..."
GoTo Test_OpenExit
End If
varFileName = OpenFile.strGOFFile
Hope this helps.
Lenora