Opening a file command doesn't work

  • Thread starter Thread starter Andyjim
  • Start date Start date
A

Andyjim

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
 
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
'''------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top