Select a file to open

C

CLR

Hi All.......

The following code works fine in XL2007, but I am working in XL2000 and it
won't run there. Does anyone know how I can achive the same thing in XL2000,
please?

Dim strFile As Variant
On Error GoTo 200
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Filters.Add "Excel Files", "*.xl*"
.InitialFileName = ThisWorkbook.Path & "\"
.Show
strFile = .SelectedItems(1)
End With
Application.DisplayAlerts = False
Application.EnableEvents = False
Workbooks.Open Filename:=strFile

TIA
Vaya con Dios,
Chuck, CABGx3
 
J

Jim Cone

Hi Chuck,

These display the File Open dialog and then open the file selected.
Works in XL97

'Built-in path...
Application.Dialogs(xlDialogOpen).Show Application.LibraryPath
'Already there...
Application.Dialogs(xlDialogOpen).Show ThisWorkbook.Path
'Specific path...
Application.Dialogs(xlDialogOpen).Show "C:\Documents and Settings\CLR\My Documents\Excel Files"
--
Regards,
Jim Cone
Portland, Oregon USA



"CLR" <[email protected]>
wrote in message Hi All.......

The following code works fine in XL2007, but I am working in XL2000 and it
won't run there. Does anyone know how I can achive the same thing in XL2000,
please?

Dim strFile As Variant
On Error GoTo 200
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Filters.Add "Excel Files", "*.xl*"
.InitialFileName = ThisWorkbook.Path & "\"
.Show
strFile = .SelectedItems(1)
End With
Application.DisplayAlerts = False
Application.EnableEvents = False
Workbooks.Open Filename:=strFile

TIA
Vaya con Dios,
Chuck, CABGx3
 
D

Don Guillett

xl2003 example of one I did for a client recently. Opens the folder and lets
you select the file to use

Sub SAS_OpenFileToCheck()
Fn = Application.GetOpenFilename(FileFilter:= _
"Excel Files (*.xls), *.xls", Title:="Please select a file")
If Fn = False Then
MsgBox "Please start over and select a file", Title:=" SalesAid
Software"
Exit Sub
Else
Workbooks.Open Filename:=Fn
'MsgBox Fn

'Call SAS_ColorCellsFromCodeFile

MsgBox " All Done Be sure to SAVE file ", Title:=" SalesAid Software"

End If
End Sub
 

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

Top