View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
sebastienm sebastienm is offline
external usenet poster
 
Posts: 694
Default Opening a file command doesn't work

Hi,
try GetFile:
''' -------------------------------------------
Function GetFile() As String
Dim fd As Office.FileDialog
Dim action As Long

Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.ButtonName = "Select file"
.Title = "Select Update file"
.Filters.Clear
.Filters.Add "Excel Files", "*.xls"
.InitialFileName = "Updatefile.xls"

action = .Show
If action = 0 Then ''' user cancelled
GetFile = ""
Else
GetFile = CStr(.SelectedItems(1))
End If
End With
End Function
'''------------------------------------------------
--
Regards,
Sébastien
<http://www.ondemandanalysis.com
<http://www.ready-reports.com


"Andyjim" wrote:

We have a VB program and runs from one file and tries to open another file
which is located in the same directory. The other file is called
"Updatefile.xls." THis macro runs fine at one computer that has Excel 2003,
but doesn't work on another computer that has Excel 2000. It will open on
the Excel 2000 computer if you provde the entire path.

Is this an Excel version problem or something else? If not, why does it run
on one computer (opening the 2nd file), but not on the other. If so, is
there a way to provide the path programmatically (we do not know where
various users of this program will put their files?)

Thanks for all your help