ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening a file command doesn't work (https://www.excelbanter.com/excel-programming/403141-opening-file-command-doesnt-work.html)

Andyjim

Opening a file command doesn't work
 
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

sebastienm

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



All times are GMT +1. The time now is 01:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com